I develop a vb.net application, and I'm having troubles with comboboxes.
I have this to know when the selected item on my combobox is changed :
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
And the RequestAccessv2() function
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
And there is the result on the output, when the second function is called, I don't have the same selectedIndex :
ActionListenerIndex = 2
SELECTED INDEX SITE : -1 'Does it means thas nothing is selected ?
Have you already had/solved this problem ?
Regards, Fabien
Thanks for your answers !
Indeed Steve and A Friend the problem was coming from the function initBoxesLocation. In this fuction I was clearing 4 comboboxes, then I added 1 item on each.
I didn't realy understand where does the problem comes.
edit : Yes of course, once my comboboxes refiled I didn't selected an item again so there is the problem.
Private Sub initBoxesLocation()
Console.WriteLine("initialisation entete")
initBoxEnteteSite()
initBoxEnteteBuilding()
initBoxEnteteModule()
initBoxEnteteRoom()
End Sub
I split the initBoxesLocation() function, by calling one or an other reset function depending on the combobox changed, I needed actually not to call them all.
Now it works !
Regards Fabien