By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,534 Members | 1,830 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,534 IT Pros & Developers. It's quick & easy.

Clearing last item from combobox?

P: n/a
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

Oct 31 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi Brett,

Try the following:

mycbox.Text = null;

--
Dave Sexton

"Brett Romero" <ac*****@cygen.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
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

Oct 31 '06 #2

P: n/a
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.
On Tue, 31 Oct 2006 02:16:39 +0100, Brett Romero <ac*****@cygen.comwrote:
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


--
Happy Coding!
Morten Wennevik [C# MVP]
Oct 31 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.