ComboBoxEx and Events

I added a ComboBoxEx control to my form and populated it with data from the database. I set AutoSuggest, AutoAppend and UpDownKeyDropsList to true.

At first I tried the OnSelect event - it does not fire. If I type combobox and select an item from the drop-down list.

Then I tried the OnDropDown event - it does not fire if the dropdown menu is omitted.

Now, how can I get the selected item when the item is selected?

+4
source share
1 answer

If I do not understand the question, I think the answer you are looking for is the onChange event, then use ComboBox.Items [ComboBox.ItemIndex] to get the selected item.

EDIT: you can also check if ComboBox.ItemIndex <> -1 is in the onChange event. Using this, you can bypass your important event code every time a letter is typed.

Although I just did a quick test, there is still a problem that after selecting an item, any input will be selected after it is not captured by "itemIndex <> -1", since it was installed. Although this seems like a good start.

+3
source

Source: https://habr.com/ru/post/1332199/


All Articles