如何禁用将用户值键入 Windows 表单组合框的选项?
How to disable option of typing user values to Windows Forms Combobox?
我有 winforms 组合框。我有我放入 Items
集合中的预定义值列表。我想让用户只选择这个值,而不是输入他们自己的值。
我该怎么办?
将其 DropDownStyle 设置为 DropDownList
将 属性 DropDownStyle 设置为 ComboBoxStyle.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.
The list displays only if AutoCompleteMode is Suggest or
SuggestAppend.
我有 winforms 组合框。我有我放入 Items
集合中的预定义值列表。我想让用户只选择这个值,而不是输入他们自己的值。
我该怎么办?
将其 DropDownStyle 设置为 DropDownList
将 属性 DropDownStyle 设置为 ComboBoxStyle.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. The list displays only if AutoCompleteMode is Suggest or SuggestAppend.