使用模块在VB.net中启用和禁用cbomboBox

时间:2016-03-07 18:37:56

标签: vb.net combobox

我正在尝试启用和禁用两个组合框,具体取决于选择。

Public Function itemsEnabled(item, item2)
    Dim cboCate As String
    Dim cboItemM = frmStore.cboItem
    Dim cboItemM2 = frmStore.cboItem2
    cboCate = frmStore.cboCategory.SelectedItem
    cboItemM = frmStore.cboItem
    cboItemM2 = frmStore.cboItem2
    Try
        If cboCate = "Coffee" Then
            cboItemM.Enabled = True
            cboItemM2.Enabled = False
            'if coffee is chosen then colddrink combo box is disabled
        ElseIf cboCate = "ColdDrink" Then
            cboItemM2.Enabled = True
            cboItemM.Enabled = False
            'if colddrink is chosen then coffe combo box is disable
        End If
    Catch ex As Exception
        MessageBox.Show(ex.ToString())
    End Try
    Return cboItemM
End Function'

当我在cboCate(类别)中选择一个选项时没有任何反应,我尝试在第5行的末尾添加ToString(),但我收到错误:

  

对象引用未设置为对象的实例。

0 个答案:

没有答案