Hi guys,
I have bit trouble with the code, I have two comboboxes with list1 and I am trying to block the code to stop them passing with other code and go to the wrong way around. When I selected the first item on combobox1, the setselected moved to item2 on list1. I am trying to stick the code on combobox1 with the first item on the list1 when I select any of items from combobox1 and hope for the return when I do on combobox2 to go with second item on list1.
Here it the code:
Code:Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged If ComboBox1.SelectedItem = "Item1" Then List1.Items.Clear() List1.Items.Add(My.Resources.RuntimeStrings_test.1) List1.Items.Add(My.Resources.RuntimeStrings_test.2) If Me.ComboBox1.Items.Count > 0 Then List1.SetSelected(0, True) End If End Sub Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged If ComboBox1.SelectedItem = "Item2" Then List1.Items.Clear() List1.Items.Add(My.Resources.RuntimeStrings_test.1) List1.Items.Add(My.Resources.RuntimeStrings_test.2) If Me.ComboBox1.Items.Count > 1 Then List1.SetSelected(1, True) End If End Sub
I have also tried this
Code:Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged If ComboBox1.SelectedItem = "Item1" Then List1.Items.Clear() List1.Items.Add(My.Resources.RuntimeStrings_test.1) List1.Items.Add(My.Resources.RuntimeStrings_test.2) If ComboBox1.SelectedItem.Count = 0 Then List1.SetSelected(0, True) End If End Sub Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged If ComboBox1.SelectedItem = "Item2" Then List1.Items.Clear() List1.Items.Add(My.Resources.RuntimeStrings_test.1) List1.Items.Add(My.Resources.RuntimeStrings_test.2) If ComboBox2.SelectedItem.Count = 1 Then List1.SetSelected(1, True) End If End Sub
It didn't works![]()
I am trying to make the code in separate but they are making like a loop and I have no where to make it go different.
Hope you guys can help me with this.
Thanks,
Mark




