Ask the Expert

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

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

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: