I am facing a problem in setting the combo property such that only user can select the values form given items, but I cannot write in the combo box.
How can I do so in C#?
To make the text portion of a ComboBox non-editable, set the DropDownStyle property to "DropDownList". The ComboBox is now essentially select-only for the user. You can do this in the Visual Studio designer, or in C# like this: stateComboBox.
Right click the Combo Box you want to disable typing, then click Properties from the right-clicking menu. See screenshot: 3. In the Properties dialog box, select 2 – fmStyleDropDownList from the Style drop-down list, and then close this dialog box.
Set the DropDownStyle property of the combobox to DropDownList . This will allow only items in the list to be selected and will not allow any free-form user input.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With