views:

641

answers:

1

So there are a bunch of questions similar to mine, but none exactly what I need. I have a combobox that is populated with a list of cities. I turned on the Autocomplete and that works exactly how i want with the suggestappend also turned on. The problem is, though, if the user tries to tab out of the combo box, it does not actually select the item. here is an example: I am searching for "Orlando". If i type in "orla", the suggestion fills out the rest of the word (selected), so it shows "orlando". So that is the item I want to select. If i hit enter and then tab out, it will select the item and then tab out. What i need though, is for tabbing out to select the underlying item that matches the word. If i need to explain more, I can. Thanks in advance!

Luke

A: 

Which version of .NET are you using? I tried it in 3.5, and the behavior is the opposite of what you describe. When I type a partial name and tab out, it selects the item in the list. If I hit enter, it doesn't select the item, and it actually clears the value I just entered.

How are your properties set on the ComboBox? I have AutoCompleteMode = SuggestAppend and AutoCompleteSource = ListItems.

Albert Walker
Same behaviour in 2.0 (tabbing out does select)
Sorin Comanescu
I am using 3.5 sp1. What happens for me is when I tab out, it fills in the rest of the text (but doesnt capitalize the first letter), and doesnt select the binding item. I have an event handler on the onLeave for the combo box, so that gets fired after the tab is hit. When it gets fired, the comboBox.SelectedItem == null. I have this event handler on there because I need to make sure that they do not leave the box without selecting a city, because they aren't allowed to add a new one.
luke
Ok so we are both right, in a way. At the time the onLeave event is fired, the item has not been selected yet. Once it has left, though, it selects the item. So my new question is, do you know of a way that I can restrict leaving the comboBox without an item selected? I cannot use the onLeave because it hasn't been selected yet.
luke