473,772 Members | 2,292 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Selected Text = 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 5219
Hi Brett,

Try the following:

mycbox.Text = null;

--
Dave Sexton

"Brett Romero" <ac*****@cygen. comwrote in message
news:11******** **************@ k70g2000cwa.goo glegroups.com.. .
After I remove all items from a combobox, the last selected item
remains in the display area. I've tried:

mycbox.Selected Text = 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.Selected Text = 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
3453
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 = Insurer.InsurerName ValueMember = Insurer.InsurerId DataBindings.SelectedValue = Contact.InsurerId It generally works fine. I am able to navigate records and
4
2116
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 Combobox1.text = " am i using the wrong event
0
291
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 item selected in Combobox 1. This is done through the .AddItem method of Combobox 2 looping through the recordset. This works fine, until --> the data item in the Combobox 1 is changed, then Combobox 2 just appends the "new" related child data...
4
2247
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 question is: is it possible to do this? What other things might I try? # Reset Pythonwin enviroment # Variables keep =
4
6666
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 common/standard .NET control accepting an Object as a parameter type? In Web Forms, there is a ListItem object that can be passed in to add/retrieve objects from a DropDownItems collection. I searched Google groups, and all the solutions I'm finding...
1
1742
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. i don't want that. i used to clear it up by setting ComboBox1.Text="", after loading it. but i had to put the combobox on a tab page of a tab control. ComboBox1.Text="" works only if the tab page has the focus when that code
7
3582
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 Me.cboLocation.Text = ""
2
3684
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 different item no in it..then, these records will be saved in a temporary datatable (which i made in a separate class, the name is WBASKET)...The item nos of these records will be displayed in a combobox, say item1, item2, etc.. then,i have a datagrid...
21
2566
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 presedentsjob
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10264
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2851
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.