开发者

ComboBoxEx and events

开发者 https://www.devze.com 2023-01-31 04:59 出处:网络
I added ComboBoxEx control to my form and populate it with data from database. I set AutoSuggest, AutoAppend and UpDownKeyDropsList to true.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消