[RESOLVED] Combobox ListIndex
I am trying to have the index value of a selected item in a combobox returned to a variable. Then, if the variable = 1 (which would be the index of th second item in the combobox), I want a groupbox to be hidden (be invisible) on the form. Here is my code...Getting an error that says:
'ListIndex' is not a member of 'System.Windows.Forms.ComboBox'
Code:
Private Sub cbxAccounts_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim selection As Integer = CInt(cbxAccounts.ListIndex)
If selection = 1 Then gbxCheck.Hide()
End Sub
Re: [RESOLVED] Combobox ListIndex
This works now. It took some work, but I got it going. Here is the code:
Code:
Private Sub cbxAccounts_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbxAccounts.SelectedIndexChanged
' Hide "Check" Groupbox when "Savings" is selected from "Accounts" Combobox
Dim selection As String = cbxAccounts.SelectedItem
If selection = "Savings" Then gbxCheck.Visible = False Else gbxCheck.Visible = True
End Sub