DesktopComboBox Text vs SelectedIndex/Value

Using the standard desktop combobox I find what is to me an odd behavior, even when AutoComplete = True.

Assume a ComboBox full of US state names and AutoComplete = true. one types NO and it autocompletes to North Carolina – well and good. The user now moves on to other controls and presses Save to validate and save the entered info.

At this point, the code looks at the SelectedValue of the combobox and it is unchanged by what has been autocompleted into the Text property. It could look at the Text property instead but how does it know if the user entered the text or used the drop down?

This is easily fixed with a few lines of code in the Focus Lost event of the combo box to sync up the selected value with the autocompleted value, but before I go subclassing DesktopComboBox and using my subclass everywhere I just want to do a sanity check and see if there’s some other functionality I’m missing since the default behavior seems quite odd to me. I suppose one might want this behavior if the user has the option to type random things not in the drop down list, but in my experience users expect to be constrained by the drop down and to just have a couple ways of choosing the constrained legal values. And I would expect in that situation you probably wouldn’t use AutoComplete = True anyway.

So … am I, in fact, missing something?

Thanks!

1 Like

It worked in r2012. But despite my pleas to fix it in rel. 2013 to present it never was. You will have to either: subclass it or make your own using a textbox with a listbox.

1 Like

Thanks Henry. If it helps any, there are little things like this that have been enshrined in other products made by, let us say, companies with a lot more resources, that have been this way for years and years. Sometimes they get left in there too long and people start relying on the (mis)behavior and it becomes more trouble to fix than to leave alone. I don’t mind (too much) if there are acceptable workarounds. Appreciate the confirmation, and so subclassing it is then.