と の 2 つがListBox1ありListBox2ます。ListBox2項目を選択して、次のコードで項目を に挿入しましたListBox1。
da6 = New SqlDataAdapter("select distinct(component_type) from component where component_name='" & ListBox1.SelectedItem() & "'", con)
da6.Fill(ds6, "component")
For Each row As DataRow In ds6.Tables(0).Rows
ListBox2.Items.Add(row.Field(Of String)("component_type"))
Next
しかし、別のアイテムを再選択するListBox1と、ListBox2プリロードされたアイテムと現在ロードされているアイテムが一緒に表示されます。今ロードされたアイテムだけをリストボックスに表示したい。このコードを使用しましたが、問題は解決しませんでした:
For i =0 To ListBox2.items.count - 1
ListBox2.Items.removeAt(i)
Next
OR
listbox2.items.clear()も機能していません..
内のすべてのアイテムをクリアするにはどうすればよいListBox2ですか?