Prevent Edit of a Combo Box

I have several combo boxes in an application I'm working on. I don't want to allow the users to just type something into the combo box - infact - I want them to be able to select ONLY a list item in the combo box.

I am still not sure if I want to allow them to type in the field (and catch the case where the typed value does not exist in the list) or to completely stop typing in the field. My personal preference (and from what I can tell the easier of the two options) would be the later.

I've played with validate, and lost focus. They don't quite behave how I want them to. For example, a user could type in string, click the continue button. This would call the lost_focus event which would determin that the string was bad, set the combo to some value (user would have no control of this) and then continue on...

Any ideas/code fragments greatly appriecated.

Who is Participating?
rspahitzConnect With a Mentor Commented:
If I understand you correctly, what you're looking for is in the Style property...set it to 2-Dropdown List.
woottondAuthor Commented:
perfect... now I have to figure out how to set the initial value - dum dee dum dum...

woottondAuthor Commented:
done and done.

Thanks - save me hours of stupid work around coding.


Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

>now I have to figure out how to set the initial value

Set the listindex property to correspond to the item you want.  (Points go to rspahitz)
Combo1.Text = IntialValue


Combo1.ListIndex = Item_Between_0_And_ListCount-1

Glad to help.
woottondAuthor Commented:
yes -- got the listindex as soon as I looked at it, not sure why I hadn't thought to use the style property! had been playing with everything from lccked, enabled, to on_lost_focus, to validate...

cheers guys,
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.