ComboBoxEx and events
I added ComboBoxEx control to my form and populate it with data from database. I set AutoSuggest, AutoAppend and UpDownKeyDropsList to true.
First I开发者_如何学C tried OnSelect event - it doesn't fire If I'm typing to combobox and selecting an item from dropdown.
Then I tried OnDropDown event - it doesn't fire either if dropdown is dropped down.
Now how can I get selected item when item is selected?
Unless I don't understand the question I think the answer you are looking for is the onChange event and then use ComboBox.Items[ComboBox.ItemIndex] to get the selected item.
EDIT: You could also check to see if ComboBox.ItemIndex <> -1 in the onChange event. Using this you could get around doing your important code for the event each time a letter is typed.
Although I only did a quick test, there is still issue with once an item is selected any typing after that doesn't get caught by "itemIndex <> -1" since it has been set. Though this seems like a good start.
精彩评论