简体   繁体   English

他们是在使用另一个 combobox 后禁用 combobox 的方法吗? vb.net

[英]Is their a way to disable a combobox after using another combobox? vb.net

So I am making a simple register system and I am using 3 ComboBox and I want to know if their is a way to disable the 2 other ComboBox if I selected an item from 1 ComboBox?所以我正在制作一个简单的注册系统,我正在使用 3 ComboBox,我想知道如果我从 1 ComboBox 中选择一个项目,它们是否是禁用另外 2 个 ComboBox 的方法?

You can set the Enabled property to False on the other two combo boxes in the SelectedIndexChanged event.您可以将 SelectedIndexChanged 事件中其他两个组合框的 Enabled 属性设置为 False。 Just make sure that the SelectedItem property of your combo box is not null before disabling the other two:在禁用其他两个之前,只需确保组合框的 SelectedItem 属性不是 null:

Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
    If ComboBox1.SelectedItem IsNot Nothing Then
        ComboBox2.SelectedItem = Nothing
        ComboBox2.Enabled = False
        
        ComboBox3.SelectedItem = Nothing
        ComboBox3.Enabled = False
    End If
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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