Bruce
Bruce

Reputation: 2213

Winforms Combobox - do not allow user to edit items

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

Upvotes: 25

Views: 45247

Answers (5)

Khalid
Khalid

Reputation: 645

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.

Upvotes: 1

CharithJ
CharithJ

Reputation: 47530

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.

Upvotes: 15

Steve Sloka
Steve Sloka

Reputation: 3454

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.

Upvotes: 1

Waqas
Waqas

Reputation: 6802

Set the ComboBox style to ComboBoxStyle.DropDownList

Upvotes: 4

Alex F
Alex F

Reputation: 43311

Set DropDownStyle = DropDownList.

Upvotes: 52

Related Questions