Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clear ComboBox selected text

I have a ComboBox control with the DropDownStyle properties set to DropDownList. Once there is an item selected, how can I clear the selection from the ComboBox without deleting any Items in it ?

I'd normally use something like that:

myComboBox.Text.Clear();

But I can't do that. Any idea how I could clear it ?

like image 562
phadaphunk Avatar asked Aug 31 '25 18:08

phadaphunk


2 Answers

You could change SelectedIndex property:

comboBox1.SelectedIndex = -1;
like image 179
ionden Avatar answered Sep 02 '25 09:09

ionden


The only way I could get it to work:

comboBox1.Text = "";

For some reason ionden's solution didn't work for me.

like image 28
Darrell Lloyd Harvey Avatar answered Sep 02 '25 09:09

Darrell Lloyd Harvey