Results 1 to 2 of 2

Thread: "VB.NET" when using two comboboxes how can I list values based on previous selection?

Hybrid View

  1. #1
    Hyperactive Member simpleonline1234's Avatar
    Join Date
    Mar 10
    Posts
    320

    "VB.NET" when using two comboboxes how can I list values based on previous selection?

    I have two comboboxes on my application. The first combobox contains some main values. I'm trying to figure out how to make my app give me only values based on whatever I chose in my first selection.

    Any ideas?

    I tried this but no go.

    Code:
    Public Class Form1
    
        Private Sub TypeCombo_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FootprintTypeCombo.SelectedIndexChanged
            If LinkTypeCombo.SelectedItem = MainLink" Then
                FootprintTypeCombo.Items.Add("test")
            End If
    
    
        End Sub
    End Class
    
    An example of what I'm trying to do is say that I have the first combobox as menu type of a restaurant  > Breakfast, Lunch, Dinner.
    
    I am trying to find a way to only give me values in the second combobox based on the first selection so if breakfast was selected only breakfast selections would appear in the second drop down.
    
    
    Thanks
    Are you down with OOP?

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 12
    Posts
    5,471

    Re: "VB.NET" when using two comboboxes how can I list values based on previous select

    The three things you'll need (I'll leave it to you to work out where you put 'em)

    vb.net Code:
    1. Dim breakfast() As String = {"egg", "bacon", "toast"} 'or some other way to build an array
    2.  
    3. ComboBox2.Items.Clear() 'pretty obvious
    4.  
    5.  
    6. ComboBox2.Items.AddRange(breakfast) 'or other arrays for dinner or lunch or supper or brunch or .....

Posting Permissions

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