Click here to Skip to main content
15,886,963 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How do I make a combobox control almost like read only in the sense that the user may only select one of the items but not type in any input. In other words, the only inut accepted by the ComboBox may be an item selected by the user, nothing else. I cant find a property related to that in the control. Is the some code for this purpose that I can use to prevent user typing their own data and force them to select an item?

Please note that i would like to keep the dropdown style as dropdown list but just make the normally editable portion of the control a read only. The text portion must still be visible but read only at the same time. can that be done through code? if so, how?

I am aware of the different DropDownStyles, I need DropDown style to be applied and the editable portion of the text to be overridden as read only. Can anyone please help?
Posted
Updated 2-Feb-12 5:01am
v4
Comments
Richard MacCutchan 2-Feb-12 8:41am    
I have deleted your duplicate of this question. If you have additional information then add it above.

DropDownStyle property is used to gets and sets the style of a ComboBox. It is a type of ComboBoxStyle enumeration.
The ComboBoxStyle enumeration has following three values.

Simple - List is always visible and the text portion is editable.
DropDown List is displayed by clicking the down arrow and that the text portion is editable.
DropDownList - List is displayed by clicking the down arrow and that the text portion is not editable.

Please check to ensure, it is last property assigned.
 
Share this answer
 
Comments
Winston_D 2-Feb-12 8:18am    
ugh, problem. it does solve the problem to an extent but creates an new problem. I would like the ComboBox to have the same visual style as when it is in the Drop Down List setting, almost like that of a TextBox but with the read only property set to true
I have again deleted your repost of this question. Ravi has explained what the options are in a ComboBox, which can be confirmed by reading the documentation here[^]. If you have further information to add then please edit the above question; don't repost elsewhere just to get the same answer from someone else.
 
Share this answer
 
Comments
Winston_D 2-Feb-12 10:59am    
I am aware of the DropDownStyles avaliable. That is not the problem. I am not getting an answer whether the editable portion of the text can be overridden to be read only when the DropDownStyle is DropDown. I need the style to be DropDown. Can you please help if the problem is clear and you know how to solve the problem?
Richard MacCutchan 2-Feb-12 11:26am    
There is nothing in the ComboBox properties that will let you do what you want. You could see if there is any way to get a reference to the TextBox control itself and try setting that to read only. Although I am at a loss to see what you would gain by not using the feature that is already available.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900