23

This is probably something simple. The winforms combobox items by default can be edited by the user, how to disable this?

Amittai Shapira
  • 3,749
  • 1
  • 30
  • 54
Bruce
  • 2,133
  • 12
  • 34
  • 52
  • 1
    possible duplicate of [Readonly ComboBox in WinForms](http://stackoverflow.com/questions/162936/readonly-combobox-in-winforms) – Hans Olsson Sep 26 '11 at 12:14
  • possible duplicate of [How can I make a ComboBox non-editable in .net?](http://stackoverflow.com/questions/85702/how-can-i-make-a-combobox-non-editable-in-net) – nawfal Dec 29 '13 at 02:15

5 Answers5

50

Set DropDownStyle = DropDownList.

Alex F
  • 42,307
  • 41
  • 144
  • 212
  • 1
    These answers should be rejected. Simply setting the comboxbox to a DropDownStyle of "DropDownList" takes away the ability of the user to start typing and filtering the list based on user input. This is extremely helpful for large lists. – David P Mar 24 '20 at 13:39
  • @DavidP it is a working solution and it should not be rejected based on just that aspect. Your comment is valuable though. – Alex P. Jan 26 '23 at 22:47
14

Set the ComboBox.DropDownStyle to DropDownList.

ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList;

Specifies that the list is displayed by clicking the down arrow and that the text portion is not editable. This means that the user cannot enter a new value. Only values already in the list can be selected.

CharithJ
  • 46,289
  • 20
  • 116
  • 131
4

Set the ComboBox style to ComboBoxStyle.DropDownList

Waqas
  • 6,812
  • 2
  • 33
  • 50
1

two Method that help you Stop User to not Edit DropDownList:

A. using Programming code:

DropDownListName.DropDownStyle = ComboBoxStyle.DropDownList;\

B. using Design properties of Visual Studio

Set DropDownStyle = DropDownList.

I hope this well help you.

Khalid
  • 603
  • 9
  • 22
1

Try setting the DropDownStyle property to DropDownList. Style of Simple makes it like a listbox, Combobox is what you are seeing allowing editing, and DropDownList only allows user to select.

Steve Sloka
  • 3,444
  • 2
  • 22
  • 29