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!

ComboBox styles

Status
Not open for further replies.

Denster

Programmer
Apr 9, 2001
198
0
0
GB
What is the best way to prevent the user entering data in a ComboBox?. I need to update the list programaticaly so I cant use the "Style" property.
 
Denster,

Surely if you set the style to "Dropdown list" or "Dropdown Combo", your requirement can be satisfied? Either of these can be "loaded" progammatically. Sure the user can still "enter" something into the text part of a dropdown combo, but if you don't have any code to process it, nothing will happen! And the beauty of the dropdown combo is that you can allow your user to drop down the list, then "go to" an entry by typing letters in the text part! This can be a problem if the list is closed, because each entry found will be generate a "click" event!

Having said all that, I'm sure a dropdown list will give you what you're after, on both counts. Sorry if I've missed your point.

Best regards,
SmallCraig[upsidedown]
 
I must be missing something here. If I set the style to a dropdown combo, it will allow the user to type something in the combo box wich I dont want. A dropdown list wont allow the user to type anything in the box wich is ideal, but it wont allow me to update the list programaticaly either. It wont allow me to load the style in the program either eg :-
"cbo1.style = 2".

Any other sugestions!.
 
If you set the style to Dropdown List then the only way you can load the list is programaticaly:

cboMyDropdownList.AddItem "Item 1"
 
This is a bit confusing. List box means user can't add data. Combo box means user can add data. Simple means not dropdown, dropdown means dropdown. :)

ListBox is just a list box, doesn't have dropdown capability. Later on, there was a combo box as well. Rather than change the ListBox control to include dropdown capability, the dropdown list box got added to the combobox control. If you set Style in combobox to dropdown list, it isn't really a combo box, it's a dropdown list box.

Ok? :)

Bob Rodes
 
Ok It is me missing something, thanks to BobRodes for clarifying the different styles. The alarm I was getting was nothing to do with the list. All that is needed is a dropdown list, but I wanted some text displaying in the ComboBox on initial form load like "Select Something" wich you cant do on a drop down list. I eventualy ended up putting "Select Something" in the list then remove it after the first press.
 
That'll work. If for some reason you don't want to fool around with the values in the list box, the other thing you can do is superimpose a label on it and play around with the visible properties.

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top