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

Changing a combo box

Status
Not open for further replies.
Aug 9, 2001
23
0
0
GB
Any ideas how to make the list of a combo box non-editable, i.e. only allow people to select the data from the list and not type it in (as with VB6 for example)?

Thanks,

Thom.
 
Set the "Limit to List" property to Yes in the properties of the combo box.

Joe Miller
joe.miller@flotech.net
 
On your list box properties, go to the data tab and change the limit to list property to 'YES' The hardest questions always have the easiest answers.
 
I should have explained myself better. With the LimitToList property on, users can still type in a wrong answer before the message is thrown up.

I meant so that the user cannot type in the combo box at all, merely select an option.

 
Well, you can't make it exactly like VB6, but you can change the characters that the user types to nothing, cancelling them out and achieving the same effect. In the KeyPress event of the combobox in question put this:

KeyAscii = 0

Then it will nullify all keypresses while the user is in that combobox, forcing them to use the mouse. I don't understand why you'd want to do this though, forms are normally used for data entry, and data entry is slowed down horribly if you have to reach for the mouse all the time.

My $0.02

Joe Miller
joe.miller@flotech.net
 
The one i had in mind is for a Q&A Search Engine I am currently assembling. All of the Q&A data adhears to a particular 'type' (eligibility for example). In order for the user to search using the type function it would make sense to only let them select the 'types' that are available.

Thanks for the tip.

Thom.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top