Reputation: 95
I am using Microsoft Visual Studio 2010
I have two Combobox.
-Combobox1.Text
-Combobox2.Text
first combobox1 contains the ff: items
-Globe
-Smart
-Sun
Second combobox2 contains the ff items:
-Smart30
-Smart60
-Smart115
-AMAX
-Globe30
-TU20
-TU50
-TU150
-DCTU100
What I want to do is when I click for Globe in ComboBox1.Text -AMAX and -Globe 30 Appears in the second ComboBox2., and for Smart when I clicked it., -Smart30,-Smart60 and -Smart115 appears in ComboBox2.,just like in SUN.,
So is it possible to do this?
Upvotes: 0
Views: 237
Reputation: 94645
You should have to store these data into a Dictionary<string,List<string>
and use data-binding technique to assign List<T>
to comboBox2 of selected Key
of ComboBox1
.
Sample:
Dim data As New Dictionary(Of String, List(Of String))
data.Add("Select", New List(Of String))
data.Add("First", New List(Of String) From {"A", "B", "C"})
data.Add("Second", New List(Of String) From {"P", "Q"})
ComboBox1.DataSource = data.Keys.ToList()
AddHandler ComboBox1.SelectedIndexChanged,
Sub(sa, ea)
ComboBox2.DataSource = data(ComboBox1.Text)
End Sub
Upvotes: 1