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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combobox text selection using keyboard

Status
Not open for further replies.

kunmun23

Programmer
Oct 28, 2003
17
0
0
IN
Hi,
I have a combobox for US states in my code. I want the user to be able to select a state just by pressing keys.

For instance, if the user presses "N" key then the listindex of the combobox changes to "NC" (North Carolina).

Subsequent pressing of the "N" key should show
"ND", "NE", "NJ" ..and so on.

If the user presses the "A" key the combobox should show "AK" ,"AL" and so on.

I found a piece of API code (URL Given below) that seems to do something similar. It tries to show a choice from the combobox based on the keys typed in by the user.
However my comboboxes are not editable ie the style is set to dropdownlist. The search is based only on the key pressed...if the "N" key is pressed repeatedly..all the choices that start with "N" are shown in circular manner....if a different alphabet key is pressed all the choices from the combobox list starting with that alphabet are shown in a circular manner.

URL:
I'm not an API programmer and couldn't figure out how the above piece of code works.

Could anyone explain or show me the way to implement the above.

Thanks.
 
This is already the defaut behavior of the standard Combobox when set to style 3-DropDownlist.
 
not exactly....when I press an "N" key it shows the first choice starting with an "N" ....and subsequent pressing of the "N" key scrolls it fine....BUT after that if I press, lets say "A" key it does not goto choices starting with an "A" alphabet.
Any suggestions ?
 

There is an example in this thread222-615368 of using a modified SendMessage API that may help you to accomplish what you want. Granted this example uses a text box but you can use the combo box change event instead.

Good Luck

 
ok what DrJavaJoe said is correct...as long as you don't have the Sorted property set to False. If you set the Sorted property to True, it behaves strangely. Meaning that when I press N it goes to items starting with N.
After that if I press A nothing happens...if I wait 2-3 seconds and then press A again it does go to the items starting with A.
Has anyone observed this strange behavior....any work-arounds ?

 
ooops..sorry some confusion in the above post..here's a corrected version.

what Dr.JavaJoe says works as long as you have the Sorted property of the Combobox set to False. If you set the Sorted property to True, it behaves strangely. Meaning that when I press N it goes to items starting with N.
After that if I press A nothing happens...if I wait 2-3 seconds and then press A again it does go to the items starting with A.
Has anyone observed this strange behavior....any work-arounds ?
 
DrJavaJoe (Programmer) Nov 5, 2003
This is already the defaut behavior of the standard Combobox when set to style 3-DropDownlist. "

I don't have style 3 dropdown in my list of options in VB 6 is there an update that I need?



 
oops that should be 2-Dropdown List or the 3rd option.

"Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top