CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2010
    Posts
    32

    [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

  2. #2
    Join Date
    Jan 2010
    Posts
    32

    Re: Combobox ListIndex

    Got it to work. 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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured