Clearing last item from combobox?

  • Thread starter Thread starter Brett Romero
  • Start date Start date
B

Brett Romero

After I remove all items from a combobox, the last selected item
remains in the display area. I've tried:

mycbox.SelectedText = string.Empty;

and

mycbox.refresh();

How do I clear the display area of a combobox after removing all of its
items?

Thanks,
Brett
 
Hi Brett,

As Dave more or less pointed out, use the Text property to manipulate the
Text field of the ComboBox.

mycbox.Text = ""; // or String.Empty or null

should work.

When you do a Clear on the ComboBox you already clear SelectedText and
SelectedValue as well. SelectedIndex is set to -1 to indicate no item is
selected. The Text property is cleared as well if the ComboBox style is
set to DropDownList, but a regular ComboBox allows for manual editing of
the Text property and will therefore not be cleared even if the items are
removed.
 
Back
Top