473,385 Members | 1,341 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Clearing last item from combobox?

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
2 5178
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Phil | last post by:
My form uses a dataset containing two tables, a base table (Contact) and a lookup table (Insurer). My combobox is bound as follows: DataSource = datasetContact DisplayMember =...
4
by: Newbee | last post by:
Hola I wanted to kno how to clear the current text that is displayed in my combobox I am filling it with a query which is run against my database I have tried this but it not work ...
0
by: rmatteson | last post by:
I am trying to figure out how to clear all items from a combobox (Access 2002). On my form, I have to comboboxes. Combobox 2 is populated with a set of child data dependent on the parent data...
4
by: Network Ninja | last post by:
I want to restart the environment occasionally to default (like I restarted pythonwin). I wrote this script. I know why it doesn't work, cause it deletes my variable (item) on each iteration. My...
4
by: Jerad Rose | last post by:
I'm baffled by this -- is there not a typed object used for ComboBox Items? Best I can tell, all of the methods for ComboBox that accept an Item are of type Object. Why in the world is a...
1
by: ray well | last post by:
i'm loading a combobox from a database in code, by setting the the DataSouce to a table, and the DisplayMember to a field. it loads the first row into the text area of the combobox automatically....
7
by: Brad Pears | last post by:
I have something strange going on - pretty sure it used to work before - and now it does not... Why does the following code not clear a combo box? Me.cboLocation.Text = String.Empty OR ...
2
by: kurtzky | last post by:
i created a form that should function as follows: i will enter a number in a textbox..then it should query from the database all the records which has that number..these records will have a...
21
by: kurai hikari | last post by:
i have a combobox from table( specialization) and i have a reports from table (managers) the combobox name is( combo1) the selections in the combo box are managersjob governorsjob...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.