I have created a Combo box with the 3 items.
And one more Combo Box with the 9 items.
When one item of 1st combo box selected,the 2nd combo box should show only 3 items out of 9 items.
how to do this?
I tried but not getting it.

here is in example :

  1. in ComboBox1 Properties i put this item :
    "Superhero"
    "Badguy"

  2. in ComboBox1 SelectedIndexChanged event, i put this code :

        Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        If Me.ComboBox1.Text = "Superhero" Then
            With Me.ComboBox2
                .Items.Clear()
                .Items.Add("Batman")
                .Items.Add("Optimus")
                .Items.Add("Superman")
            End With
        ElseIf Me.ComboBox1.Text = "Badguy" Then
            With Me.ComboBox2
                .Items.Clear()
                .Items.Add("Lex Luthor")
                .Items.Add("Megathron")
                .Items.Add("Joker")
            End With
        End If
    End Sub
    

Beats me. I tried your example (except that I factored out ".Items" to give)

With ComboBox2.Items
    .Clear()
    .Add("Batman")

etc. and it works, Sorry I took so long to respond. We got to the the cottage last weekend and I didn't get my internet hooked up until this morning.

When you say you put "Superhero" and "Bad Guy" in properties, you do mean into the Items collection, correct?

Edited 4 Years Ago by Reverend Jim: added details

This article has been dead for over six months. Start a new discussion instead.