vb.net 如何锁定组合框,使文本和项目不能被修改/删除/擦除?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25760889/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to lock combobox so that the text and items cannot be modified/delete/erased?
提问by user3418036
Is it possible lock the combobox so that the text can not be deleted/erased or modified. And make only choose the items? Thank you in advance. Hope is it possible.
是否可以锁定组合框,以便无法删除/擦除或修改文本。并且只选择项目?先感谢您。希望有可能。
回答by duDE
Set the "DropDownStyle" property of the combobox to DropDownList. This will allow only items in the list to be selected and will not allow any user input:
将组合框的“DropDownStyle”属性设置为DropDownList。这将只允许选择列表中的项目,并且不允许任何用户输入:


回答by jbutler483
Option 1
选项1
Simply set the ComboBox.Enabledto False- that way they can't change the values!
只需将其设置ComboBox.Enabled为False- 这样他们就无法更改值!
Option 2
选项 2
Otherwise, use the dropDownStyle:
否则,使用 dropDownStyle:
make DropDownStyleproperty to DropDownListinstead of DropDown
将DropDownStyle财产DropDownList改为DropDown
For more information
想要查询更多的信息
Read this article(yes, it's written in c#, but the properties are the same!)
阅读这篇文章(是的,它是用c#写的,但属性是一样的!)


the above image displays this quite well.
上图很好地显示了这一点。
EDIT
编辑
There is also a question previously asked herethat asked a similar question.
还有一个之前问过的问题,问了一个类似的问题。
回答by Francesco Menzani
You can set ComboBox.DropDownStyleto ComboBoxStyle.DropDownList.
您可以设置ComboBox.DropDownStyle为ComboBoxStyle.DropDownList.

