我开发了一个vb.net应用程序,并且遇到了组合框的麻烦。Visual Basic ComboBox.SelectedIndex
我有这样的知道什么时候在我的组合框中选择的项目被改变:
Private Sub ComboBoxSite_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBoxSite.SelectedIndexChanged
If (ComboBoxSite.SelectedIndex <> 0) Then 'If it is not the default value
Console.WriteLine("ActionListenerIndex = {0}", ComboBoxSite.SelectedIndex) 'To debug
RequestAccesv2(0)
End If
End Sub
而且RequestAccessv2()函数
Private Sub RequestAccesv2(taille As Integer)
initBoxesLocation() 'A function that clear/refill 4 comboBoxes
Console.WriteLine("SELECTED INDEX SITE : {0}", ComboBoxSite.SelectedIndex)
Select Case taille
Case 0 ..... 'Some database treatment
End Sub
而且有结果的输出,当第二个函数被调用,我没有相同的selectedIndex:
ActionListenerIndex = 2
SELECTED INDEX SITE : -1 'Does it means thas nothing is selected ?
你已经有/解决了这个问题?
问候, 法比安斯基
_initBoxesLocation_的代码是什么?看起来,你以某种方式改变了该函数中的SelectedIndex。请编辑您的问题并添加代码 – Steve
如果您“清除/重新填充组合框”,则选定的项目将被删除,并且“SelectedIndex”重置为“-1” –
实际上,第一项是在索引0处。因此,如果(ComboBoxSite.SelectedIndex <> 0)Then'不会从第二个索引更改为第一个时通过。这是打算? – djv