0

How to disable editing or hide text edit field, when DropDownStyle = Simple for Combo Box control?

Carsten
  • 11,287
  • 7
  • 39
  • 62
Dmitro
  • 1,870
  • 3
  • 16
  • 25

2 Answers2

0

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
default locale
  • 13,035
  • 13
  • 56
  • 62
0

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.

MicRot
  • 34
  • 5