开发者

Winforms Combobox - do not allow user to edit items

开发者 https://www.devze.com 2023-04-07 21:29 出处:网络
This is probably something simple. The winforms combobox ite开发者_开发百科ms by default can be edited by the user, how to disable this?Set DropDownStyle = DropDownList.Set the ComboBox.DropDownStyle

This is probably something simple. The winforms combobox ite开发者_开发百科ms by default can be edited by the user, how to disable this?


Set DropDownStyle = DropDownList.


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.


Set the ComboBox style to ComboBoxStyle.DropDownList


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号