Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I clear a combobox?

I have some combo-boxes that are set up as drop down lists, and the user can pick a number in them. I also have a Clear button that should clear the text from the combo boxes but I can't seem to get it. I've tried:

 //doesn't work  cboxHour.Text = ""; 

and

//doesn't work cboxHour.ResetText(); 

This seems like it should be so straight forward but I'm just not getting it.

like image 213
Fuzz Evans Avatar asked Feb 17 '12 01:02

Fuzz Evans


People also ask

How do I reset a combobox in Excel?

Use: ComboBox1. Value = Null to clear the value as mentioned above.

How do I reset my combo box in power app?

The easiest way to clear the second combobox is to just use Reset(). That will clear all the current selections and reset the combobox to its default selection.

How do I clear my DataSource combobox?

In order to clear the items in your ComboBox set it's DataSource to null.


2 Answers

Did you try cboxHour.Items.Clear()?

like image 106
Daniel Mann Avatar answered Sep 22 '22 05:09

Daniel Mann


If you just want to clear the current selection, but leave all of the items in the list, you can use:

cboxHour.SelectedIndex = -1 
like image 34
Hand-E-Food Avatar answered Sep 19 '22 05:09

Hand-E-Food