1
votes

net and i need help.

In my coding i have 2 combobox so lets assume combobox1 and combobox2

In my combobox1 i have 3 items(1,2,3) In my combobox2 i have 5 items lets say(1,2,3,4,5)

How do i setup my combobox to show certain items.. let say if i choose 1 from combobox1 then it will show 2,3,4 and will hide 1,5 in combobox2, if i choose 2 from combobox1 then it will show 1,5 and it will hide 2,3,4 for example..

I tried combobox2.item.add but all it did is duplicating items when i choose another item from combobox1 and play it back and forth by choosing different items in combobox1

Example code Below:

Private Sub ComboBox3_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox3.SelectedIndexChanged
    If ComboBox3.SelectedItem.ToString() = "1" Then
        ComboBox4.Items.Add("2")
        ComboBox4.Items.Add("3")
        ComboBox4.Items.Add("4")
    ElseIf ComboBox3.SelectedItem.ToString() = "2" Then
        ComboBox4.Items.Add("1")
        ComboBox4.Items.Add("5")
    Else
        ComboBox4.Items.Add("6")
    End If

End Sub
1
Rather than telling us a story about your code, why not post the actual code that isnt working?Ňɏssa Pøngjǣrdenlarp
I got some questions for you: 1. Is it a WPF, Winform, ASP.NET MCV or Webform application? 2. What have you tried? 3. Can we see your code?H. Pauwelyn
i need help that can be found here: help center, and here: How to Ask and here: tourŇɏssa Pøngjǣrdenlarp
What if you choose 3 from combobox1, then what will be displayed in combobox2?McMillan Cheng
please mark my answer as answer if it helpedChristopher H.

1 Answers

1
votes

easy..

Private sub ComboBox1_indexchanged
 combo2.items.clear
 Dim ab() As String = New String() _      {"1", "2", "3"}
 if combo1.text="1" then
 combo2.items.addrange(ab)