Populate 2nd combobox based on selction on 1st combo box

Hi,
Advance thanks. I am using 2 comboboxes. Each comboxes comb1, comb2 is already populated with values. Comb1 has A,B,C,D,E. Comb2 has 1,2,3,4,5,6,7,8,9.
If i select "A" from comb1 , should display "5","6", "9" in comb2
If i select "B" from comb2, should display "1","2","6"
etc...
Can you help me the best way to do this.

Kind regards,
Pooja
poojasureshkumarAsked:
Who is Participating?
 
HumbleBeginningsCommented:
Hi Pooja,

If I understand you correctly, adding the following two subs along with any additional "Case" lines you need should do the job...

	Private Sub Comb1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Comb1.SelectedIndexChanged
		Select Case Comb1.SelectedItem
			Case "A"
				AssignComb2Values({5, 6, 9})
			Case "B"
				AssignComb2Values({1, 2, 6})
		End Select
	End Sub

	Private Sub AssignComb2Values(ByVal vals())
		Comb2.Items.Clear()
		Comb2.Items.AddRange(vals)
	End Sub

Open in new window


Hope this helps!

Humble Beginnings :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.