Click to See Complete Forum and Search --> : [RESOLVED] Combobox ListIndex


CarlMartin
January 20th, 2010, 06:11 PM
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'


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

CarlMartin
January 20th, 2010, 09:42 PM
Got it to work. Here is the 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