hi, i have two drop down list on a form (the only form) and i was wondering is it possible to change the contents of the 2nd drop down depending on what is chosen on the first one
If I understand you correctly, the following should do the trick - this example assumes that the first ComboBox has items named "One" and "Two".
Private
Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim list1 As New List(Of String)
list1.Add(
"1")
list1.Add(
"2")
list1.Add(
"3")
Dim list2 As New List(Of String)
list2.Add(
"X")
list2.Add(
"Y")
list2.Add(
"Z")
Dim i As Integer
Select Case ComboBox1.SelectedItem
Case "One"
sorry but no i didn't explain myself properly, i meant
have about 27 lists of choices for drop down 2
so if option 1 (numbers/symbols) then the 1st list would be searchable in drop down 2 or if option 2 (A) was chosen then the 2nd list would be loaded into drop down 2
drop down list
David Gwynn-
asalcedo
In the SelectedIndexChanged event for the first ComboBox add code similar to the following:
If ComboBox1.SelectedItem = "Green" Then
ComboBox2.SelectedItem = "Yellow"
Else
ComboBox2.SelectedItem = "Red"
End If
For a large number of items, you could use a Select Case statement instead.
Hope this helps,
Steve Hoag
Visual Basic Express
trying
If I understand you correctly, the following should do the trick - this example assumes that the first ComboBox has items named "One" and "Two".
Private
Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged Dim list1 As New List(Of String)list1.Add(
"1")list1.Add(
"2")list1.Add(
"3") Dim list2 As New List(Of String)list2.Add(
"X")list2.Add(
"Y")list2.Add(
"Z") Dim i As Integer Select Case ComboBox1.SelectedItem Case "One"ComboBox2.Items.Clear()
For i = 0 To list1.Count - 1ComboBox2.Items.Add(list1.Item(i))
Next Case "Two"ComboBox2.Items.Clear()
For i = 0 To list2.Count - 1ComboBox2.Items.Add(list2.Item(i))
Next End Select
End SubHope this helps,
Steve Hoag
Visual Basic Express
mfatih
sorry but no i didn't explain myself properly, i meant
have about 27 lists of choices for drop down 2
so if option 1 (numbers/symbols) then the 1st list would be searchable in drop down 2 or if option 2 (A) was chosen then the 2nd list would be loaded into drop down 2