简体   繁体   中英

Disable combo box list

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

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

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

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

Ok, use the .Visible property....

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

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM