How to make Combobox in winforms readonly


I do not want the user to be able to change the value displayed in the combobox. I have been using Enabled = false but it grays out the text, so it is not very readable. I want it to behave like a textbox with ReadOnly = true, where the text is displayed normally, but the user can't edit it.

Is there is a way of accomplishing this?

5/8/2013 8:29:18 PM

Accepted Answer

The article ComboBox-with-read-only-behavior suggests an interesting solution:

Create both a readonly textbox and a combobox in the same place. When you want readonly mode, display the textbox, when you want it to be editable, display the combobox.

5/8/2013 8:27:08 PM

Exper Answer

The best thing I can suggest is to replace the combo-box with a read-only textbox (or just perhaps a label) - that way the user can still select/copy the value, etc.

Of course, another cheeky tactic would be to set the DropDownStyle to DropDownList, and just remove all other options - then the user has nothing else to pick ;-p

12/24/2008 7:36:01 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow