vb.net 禁用组合框列表

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16700963/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 13:42:04  来源:igfitidea点击:

Disable combo box list

vb.netvb.net-2010

提问by alwaysVBNET

I want to disable a combo box dropdown list from showing in VB.NET and then enable it. How can I do this? The default value of the cbo box should be enabled for typing. Thanks

我想禁用组合框下拉列表在 VB.NET 中显示,然后启用它。我怎样才能做到这一点?应启用 cbo 框的默认值以进行键入。谢谢

回答by fahim baxi

After Searching for same to disable combo box in vb .net cant find good answer which help... so i tried some thing like this

在 vb .net 中搜索相同的以禁用组合框后找不到好的答案,这有帮助......所以我尝试了一些这样的事情

1st thing to do while disabling

禁用时要做的第一件事

combobox1.enabled=false
combobox1.beginupdate

2nd thing to do while enabling

启用时要做的第二件事

combobox1.enabled=true
combobox1.endupdate

its looks simple and i dont found any problem but i have doubt may it effect any excecution speen or other object

它看起来很简单,我没有发现任何问题,但我怀疑它是否会影响任何执行速度或其他对象

回答by peter

Try using dropdownstyle, simple can be used to remove list by manually closing the list in designer, then u can switch between dropdown and simple to achieve what you need.

尝试使用 dropdownstyle,simple 可以通过在设计器中手动关闭列表来删除列表,然后您可以在 dropdown 和 simple 之间切换以实现您的需要。

回答by phadaphunk

I want to disable a combo box dropdown list from showing in VB.NET and then enable it.

我想禁用组合框下拉列表在 VB.NET 中显示,然后启用它。

Ok, use the .Visibleproperty....

好的,使用.Visible属性....

The default value of the cbo box should be enabled for typing

应启用 cbo 框的默认值以进行键入

Oh.... then.

哦……那么。

The bad news.

坏消息。

You can't.

你不能。

The good news.

好消息。

You simply put a textbox on top of the combobox. When the dropdown should be disable, make the combobox invisible and show the textbox.

您只需在组合框顶部放置一个文本框。当下拉菜单应该被禁用时,使组合框不可见并显示文本框。

'Goodbye Combo

Private Sub HideComboButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HideComboButton.Click

comboBox.Visible = False
txtBox.Visible = True

End Sub

'Hello Combo

Private Sub ShowComboButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowComboButton.Click

comboBox.Visible = True
txtBox.Visible = False

End Sub

回答by Manny265

Try using the Enabled method eg comboBox1.Enabled = False
Tellme how that works out for you

尝试使用 Enabled 方法,例如comboBox1.Enabled = False
Tellme 如何为您工作