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

Combo Box Drop Down Style

Status
Not open for further replies.

Katy44

Technical User
Joined
Dec 12, 2003
Messages
723
Location
GB
Hi,

I've asked a similar question before, so sorry if this is a repeat.
I have a comboBox on a Windows form. I want it to act like a Drop Down style when the user is typing in to it- for it to go to the record they are typing, but on Leave, I want some way to check that the item they have typed is actually a value in the list. I don't want them to be able to save records with un-validated text in this box. Any ideas?
 
I have done something which seems to work and seems to do what I need. It's clumsy though so here it is for anyone who wants it, but please let me know when you find the problems:

On a comboBox keydown event check that the key was the enter key, that the cb was dropped down, and that the selected index was -1.
if so, carry out the down arrow event, and then the enter key.
"SendKeys.Send("{DOWN}");
SendKeys.Send("{ENTER}");"

This means that when the user is typing in, it takes them to the closest match. If they press enter it selects this closest match. If they type in rubbish and then press enter, it selects the first entry in the list (which is fine).

If any experts have read through this and spotted possible problems then I'd be grateful to hear them, but this seems to work OK at the moment.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top