I followed the instructions at http://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.selectionchangecommitted.aspx but i have some trouble.
First, this box is empty and disabled. Then, when a search is done, it fills this combobox with values. Let’s say the values are 0=>"", 1=>"My first value", 2="My second value". I then have a handler on this box and it does trigger every time i change the value, looks like this
Private Sub MyComboBox_SelectionChangeCommitted(ByVal sender As Object, ByVal e As EventArgs) Handles MyComboBox.SelectionChangeCommitted
MsgBox(MyComboBox.SelectedText)
End Sub
If i now select number 1, I get “” in the message box. If i then select number 2, i get “My first value” and so on. It’s one step behind. It trigger before the value has changed. How can i tell it do wait for this value and after that trigger the msgbox?
MSDN specifically warns about that. SelectedText is the wrong property, you should only use it to retrieve the text that the user selected inside the textbox portion of the combobox. You do get all text selected after changing the index but that doesn’t happen until after this event runs. Use SelectedItem.ToString() instead.