How to disable editing or hide text edit field, when DropDownStyle = Simple
for Combo Box control?
-
Take a look here: http://stackoverflow.com/a/13263335/1300049 – JleruOHeP Mar 27 '13 at 11:17
-
Is it `ComboBoxStyle.Simple` or `ComboBoxStyle.DropDownSimple`? – Rob Mar 27 '13 at 11:19
2 Answers
MSDN on ComboBox.DropDownStyle:
The DropDownStyle property specifies whether the list is always displayed or whether the list is displayed in a drop-down. The DropDownStyle property also specifies whether the text portion can be edited.
Docs on ComboBoxStyle.Simple:
Specifies that the list is always visible and that the text portion is editable. This means that the user can enter a new value and is not limited to selecting an existing value in the list.
So, ComboBoxStyle.Simple
suggests that list can be edited by user and it's confusing to disable edit with this DropDownStyle
selected. Alternatives:
- If you are ok with drop-down list use
ComboBoxStyle.DropDownList
- If you want to display a non-editable list with a view similar to
ComboBoxStyle.Simple
consider using ListBox

- 13,035
- 13
- 56
- 62
-
-
@mcuw Doesn't ComboBox do the same? By the way, why do you need to hold focus on control? And I said `ListBox` not `ListView`. – default locale Mar 27 '13 at 12:12
If you really need to achieve this effect on Combox you can just catch the events like "TextChanged" and then setting it back to "" and asking if (!comboBox1.DropDownStyle == ComboBoxStyle.Simple) before adding items to Items collection. Although it seems there are better ways to achive similar functionality using listbox as suggested before.

- 34
- 5