Click here to Skip to main content
15,910,009 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How do you select an index in the list as you type for the match found in the comboBox list?

Let's assume for example that I found the right index in the comboBox by some means, how do I select the specific index in the list?

comboBox.SelectedIndex = index.....won't work. The list just moves up or down but won't highlight/get selected as I found the match.

Another thing, I want to select the complete match only. If there is no match as I type, then there will be no selection.
Posted
Updated 20-Oct-10 4:10am
v2
Comments
Tarun.K.S 20-Oct-10 12:24pm    
did it help you?
this_is_my_alias 21-Oct-10 1:44am    
Thank you for all the answers and support. I already found a way (but not that ideal). I used SendMessage() on a dummy button (hidden) to do the trick of selecting the comboBox index.
Tarun.K.S 21-Oct-10 3:59am    
ohkay!

1 solution

hi there,

suppose you want the third item in the combobox
then u can do this:

combobox1.selectedindex=2
this will select the third item.

and to get the selected item, do this:

string str = combobox1.selecteditem;
 
Share this answer
 
v2
Comments
Toli Cuturicu 20-Oct-10 12:49pm    
What is dim? And should be SelectedIndex...
Tarun.K.S 20-Oct-10 13:01pm    
i have now provided the C# version!
this_is_my_alias 21-Oct-10 0:46am    
Sorry, but your solution doesn't work. I already explicitly stated that comboBox.SelectedIndex = index won't work which is literally the same as yours.
Tarun.K.S 21-Oct-10 4:02am    
well it worked in my case!anyways good to know that u found the solution!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900