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.
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.
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".
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 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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.