ocgprogramers
ocgprogramers

Reputation: 35

Listbox does not add item to its list. If I use selection.None

I am using an array to populate my listbox. It worked fine but when I set the listbox.selection.none (I don't want items to be selected) then My listbox adds item to its first index but after that. It keeps the same value in an does not add new values. below is the code what i am using to add items to listbox from array.

Private array(10) As Decimal ' adds student score to array

dim index as integer = 0 '

Private Sub PopulateScoreList() ' method called when button is clicked
    If index < 10 Then 
        ' adds value to array at every button click event
        array(index) = Math.Round(value, 1)
    End If
    index += 1
    lbxTroopersScore.DataSource = Nothing
    lbxTroopersScore.DataSource = array 

end sub

Upvotes: 1

Views: 115

Answers (1)

LarsTech
LarsTech

Reputation: 81610

Seems like a bug. Toggling the SelectionMode property fixes the problem:

lbxTroopersScore.DataSource = Nothing
lbxTroopersScore.SelectionMode = SelectionMode.One
lbxTroopersScore.SelectionMode = SelectionMode.None
lbxTroopersScore.DataSource = array

Upvotes: 1

Related Questions