tags:

views:

48

answers:

4

i am facing a problem in setting the combo property such that only user can select the values form given items but cannot write in the combo box,

how can i do so in c#?

thanx in advance.

+5  A: 

Just change the DropDownStyle to DropDownList. Or if you want it completely read only you can set Enabled = false, or if you don't like the look of that I sometimes have two controls, one readonly textbox and one combobox and then hide the combo and show the textbox if it should be completely readonly and vice versa.

ho1
Beat me by 20 seconds!!! doh!
Ryan
@Ryan: And I even had to switch to Visual Studio to check what the property and value was called :)
ho1
@ho1: me too... you must have a faster pc.
Ryan
But please note: readonly != disabled.
Henk Holterman
@Henk: Yep, that's why I said "if you don't like the look of that..." since that's usually the main issue people find with disabling a control rather than setting it as readonly.
ho1
thanx buddy it was simple but if you don't know about this it is a mystery for you, thanx it works
moon
+1  A: 

I think what you want to do is to change the setting called "DropDownStyle" to be "DropDownList".

Ryan
A: 

This question has been asked before.

Please see here : http://stackoverflow.com/questions/85702/how-can-i-make-a-combobox-non-editable-in-net

Peter
A: 

Solution is to change DropDownStyle Property to DropDownList. It will help

scatterbraiin