Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combobox with autocomplete while dropped then tab not selecting item

Status
Not open for further replies.

jcaulder

Programmer
Apr 22, 2002
241
US
.net 1.1 VB

If you put a regular comboBox on a form. Drop the comboBox open so it shows the list of items. Start typing some text until it jumps to the first matching value. The value is highlighted in blue as if selected. However, if the user tabs from the control at this point, the selectedItem is not set to the item highlighted(and appearing) in the combobox. So it appears the user has a selected an item when in reality he has not. The selectedItem property remains set to whatever item was previously selected.

If the combobox is not dropped open when the type search occurs and the user tabs out, all works correctly. If the user clicks with the mouse on an item all works correctly. The only problem occurs when the list is dropped down, type search occurs followed by a tab.

Anyone know how to get around this issue?

Thanks,

J
 
You might be able to handle the _leave or check the keys pressed and if the key is the tab key then set the selected item to the selected Text.

-Sometimes the answer to your question is the hack that works
 
That is ultimately what I did when I did not receive any response that day. On the key press event, I capture all the keystrokes building a string with them. On lost focus event, I then set the selected item to the one matching the string captured.

I guess that would be considered a bug because it does not seem to be desired behavior to me. The same behavior does not occur in the 2.0 combobox.

Workaround is simple enough but has caused our users quite a bit of problems since the value they thought they were selecting and saving was different days later when it was reviewed.

Thanks for the reply!

J
 
I couldn't answer because I work in 2+ (2k5/8) which doesn't have that problem.

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top