我正在使用数组来填充我的列表框。它工作正常,但是当我设置listbox.selection.none(我不想要选择项目)时,我的列表框将项目添加到其第一个索引但在此之后。它保持相同的值,不添加新值。下面是我用来从数组向列表框添加项目的代码。
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
答案 0 :(得分:1)
好像是一个错误。切换SelectionMode属性可以解决问题:
lbxTroopersScore.DataSource = Nothing
lbxTroopersScore.SelectionMode = SelectionMode.One
lbxTroopersScore.SelectionMode = SelectionMode.None
lbxTroopersScore.DataSource = array