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.
精彩评论