Q

How do I link combobox items so corresponding items display when an item is selected?

How do I link combobox items with listbox items in such a way that, when a combobox item is selected, it cause corresponding item in list box to be displayed?
It's all a matter of handling the SelectedIndexChanged notification from the combo box. The following code shows how to do what you want:
Private Sub Form1_Load(ByVal sender As System.Object, _
                       ByVal e As System.EventArgs) Handles MyBase.Load
    ComboBox1.SelectedIndex = 0
End Sub

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, _
                                         ByVal e As System.EventArgs) _
                                 Handles ComboBox1.SelectedIndexChanged
    ListBox1.SelectedIndex = ComboBox1.SelectedIndex
End Sub

This was first published in October 2003

Dig deeper on Win Development Resources

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

SearchSOA

TheServerSide

SearchCloudApplications

Close