user225269
user225269

Reputation: 10913

How to clear combo box contents in vb.net

If for textbox it is textbox1.clear, etc. What is the equivalent for combobox to clear the value.

Upvotes: 8

Views: 89860

Answers (5)

When I need to clear a combo box, I use

combobox1.text=""

Upvotes: 0

Osama Rizwan
Osama Rizwan

Reputation: 615

first null the the datasource combobox.DataSource = Nothing then clear the combobox combobox.Items.Clear()

Upvotes: 0

Lilspree
Lilspree

Reputation: 135

To clear the items that are in the drop down menu combobox.SelectedIndex = -1 will work. To clear what the user types in the combobox combobox.Text = String.Empty will work because the combobox also has a text property. Use both of these to ensure it will clear the fields.

Upvotes: 0

user3455626
user3455626

Reputation: 41

If your combobox is set with the DropDownList, then use Combobox1.SelectedIndex = -1

Upvotes: 4

Dean Harding
Dean Harding

Reputation: 72658

Try using combobox.Items.Clear()

Upvotes: 20

Related Questions