Visual Studio 2010, C#
I have a ComboBox
with a DropDown
, AutoComplete
set to SuggestAppend
and the AutoCompleteSource
is from the ListItems
. The user keys data into it until the have the correct entry. Utill the data matches one of the list items, a button next to the combobox is disabled.
If the user hits the tab key the autocomplete feature accepts current suggestion. It also moves on to the next control in tab sequence that is enabled. Of course since I want it to go to the disbabled button I need to enable it as soon as I validate the entry.
The problem is that none of the events I've tried, PreviewKeyDown
, LostFocus
, SelectedIndexChanged
allow me to enable the button in time for it to be proccessed and receive the focus. It always goes to the next button in tab order which is always enabled.
I am about ready to leave the button enabled and have it give an error if pressed too soon but I don't want to do it that way. I also don't want to get into have special mode flags to keep track of when these controls receive focus. Validation seems to be a normal thing, but I'm stuck.
If the SelectedIndexChanged
worked when the user made a match this would be easy. It doesn't fire when the box clears nor when a typed match is found.
With some thought to the other answers here I came up with a partial senario that works without using AutoComplete. A side effect is that the PreviewKeyDown event is called a second time and therefore validation is called twice. I wonder why... maybe I should ask another question.
Once you turn on
AutoCompleteMode
with any setting other thanNone
, theKeyDown
event doesn't fire forTab
anymore the key is silently eaten.