"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
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:
Dim breakfast() As String = {"egg", "bacon", "toast"} 'or some other way to build an array
ComboBox2.Items.Clear() 'pretty obvious
ComboBox2.Items.AddRange(breakfast) 'or other arrays for dinner or lunch or supper or brunch or .....