Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clear combobox datasource items

Combobox datasource has been assigned with

cmbCombobox.DataSource = myCollection

where myCollection has type MyCollection: List

How can I clear items in combobox?

like image 904
hellboy Avatar asked Jan 17 '13 10:01

hellboy


2 Answers

When you data bind a control, it will synchronize with that collection. In order to clear the items in your ComboBox set it's DataSource to null.

cmbComboBox.DataSource = null;

If your combobox is not databound (no DataSource) then you can do

cmbComboBox.Items.Clear();
like image 125
Alan Avatar answered Sep 18 '22 21:09

Alan


http://support.microsoft.com/kb/327895

Me.ListBox1.DataSource = Nothing

This works for me. VB incorrectly advises the use of DBNull (which crashes).

like image 39
Andrew Avatar answered Sep 20 '22 21:09

Andrew