Hi....I want to link 2 combobox, thats means when i select 'A' from combobox1,combobox2 will show all the 'A' items in dataset, while i select 'B' it's will show all 'B' item 'B' in combobox2.
The problem is i cant clear the previous items in combobox2 with: combobox.items.clear. Why?My code is as below:
ComboBox2.Items.Clear()
If ComboBox1.SelectedIndex = 0 Then
mydataadpater.SelectCommand = New OleDbCommand
mydataadpater.SelectCommand.Connection = myconnection
mydataadpater.SelectCommand.CommandText = "SELECT Field1 FROM Product WHERE CategoriesP='1'"
mydataadpater.Fill(mydataset, "Product")
ComboBox2.DataSource = mydataset.Tables("Product")
ComboBox2.DisplayMember = "Field1"
ElseIf ComboBox1.SelectedIndex = 1 Then
mydataadpater.SelectCommand = New OleDbCommand
mydataadpater.SelectCommand.Connection = myconnection
mydataadpater.SelectCommand.CommandText = "SELECT Field1 FROM Product WHERE CategoriesP='2'"
mydataadpater.Fill(mydataset, "Product")
ComboBox2.DataSource = mydataset.Tables("Product")
ComboBox2.DisplayMember = "Field1"
End
The problem is i cant clear the previous items in combobox2 with: combobox.items.clear. Why?My code is as below:
ComboBox2.Items.Clear()
If ComboBox1.SelectedIndex = 0 Then
mydataadpater.SelectCommand = New OleDbCommand
mydataadpater.SelectCommand.Connection = myconnection
mydataadpater.SelectCommand.CommandText = "SELECT Field1 FROM Product WHERE CategoriesP='1'"
mydataadpater.Fill(mydataset, "Product")
ComboBox2.DataSource = mydataset.Tables("Product")
ComboBox2.DisplayMember = "Field1"
ElseIf ComboBox1.SelectedIndex = 1 Then
mydataadpater.SelectCommand = New OleDbCommand
mydataadpater.SelectCommand.Connection = myconnection
mydataadpater.SelectCommand.CommandText = "SELECT Field1 FROM Product WHERE CategoriesP='2'"
mydataadpater.Fill(mydataset, "Product")
ComboBox2.DataSource = mydataset.Tables("Product")
ComboBox2.DisplayMember = "Field1"
End