473,545 Members | 2,041 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ComboBox.Items. Clear()

I am populating a ComboBox at run time. I insert the first value of
"Choose Value"

cboTaxValue.Ite m.Insert(0, "Choose Value")

Then I loop through the rest of the values to be added to the combobox.

My problem is that when I try to clear the ComboBox it clears the items
that were inserted into the ComboBox, but does not clear the item I
selected in the ComboBox... For Instance.

The ComboBox has three choices: "Choose Value", ".023", ".546". I
choose ".023" from the list. After I select it, I make the needed
changes and press the update button. At the end of the UpdateButton
Method, I have a line of code: cboTaxValue.Ite ms.Clear(). This line
removes all of the items in the ComboBox except for the item I had
previously selected. I have also tried cboTaxValue.Sel ectedText =
String.Empty, that does not clear the item selected in the ComboBox
either.

Puzzled and confused I am.

I hope this was enough explanation, appreciate any help.

Scott Moore

Oct 3 '06 #1
3 18001
Use cboTaxValue.Tex t = String.Empty instead.

Thanks,

Seth Rowe

samoore33 wrote:
I am populating a ComboBox at run time. I insert the first value of
"Choose Value"

cboTaxValue.Ite m.Insert(0, "Choose Value")

Then I loop through the rest of the values to be added to the combobox.

My problem is that when I try to clear the ComboBox it clears the items
that were inserted into the ComboBox, but does not clear the item I
selected in the ComboBox... For Instance.

The ComboBox has three choices: "Choose Value", ".023", ".546". I
choose ".023" from the list. After I select it, I make the needed
changes and press the update button. At the end of the UpdateButton
Method, I have a line of code: cboTaxValue.Ite ms.Clear(). This line
removes all of the items in the ComboBox except for the item I had
previously selected. I have also tried cboTaxValue.Sel ectedText =
String.Empty, that does not clear the item selected in the ComboBox
either.

Puzzled and confused I am.

I hope this was enough explanation, appreciate any help.

Scott Moore
Oct 3 '06 #2
You can use

cboTaxValue.Sel ectedIndex = -1
or
cboTaxValue.Sel ectedItem = Nothing

to unselect a selected item.

Kelly

samoore33 wrote:
I am populating a ComboBox at run time. I insert the first value of
"Choose Value"

cboTaxValue.Ite m.Insert(0, "Choose Value")

Then I loop through the rest of the values to be added to the combobox.

My problem is that when I try to clear the ComboBox it clears the items
that were inserted into the ComboBox, but does not clear the item I
selected in the ComboBox... For Instance.

The ComboBox has three choices: "Choose Value", ".023", ".546". I
choose ".023" from the list. After I select it, I make the needed
changes and press the update button. At the end of the UpdateButton
Method, I have a line of code: cboTaxValue.Ite ms.Clear(). This line
removes all of the items in the ComboBox except for the item I had
previously selected. I have also tried cboTaxValue.Sel ectedText =
String.Empty, that does not clear the item selected in the ComboBox
either.

Puzzled and confused I am.

I hope this was enough explanation, appreciate any help.

Scott Moore
Oct 4 '06 #3
Seth,

You rock, that worked.

Thanks a lot

Scott Moore

rowe_newsgroups wrote:
Use cboTaxValue.Tex t = String.Empty instead.

Thanks,

Seth Rowe

samoore33 wrote:
I am populating a ComboBox at run time. I insert the first value of
"Choose Value"

cboTaxValue.Ite m.Insert(0, "Choose Value")

Then I loop through the rest of the values to be added to the combobox.

My problem is that when I try to clear the ComboBox it clears the items
that were inserted into the ComboBox, but does not clear the item I
selected in the ComboBox... For Instance.

The ComboBox has three choices: "Choose Value", ".023", ".546". I
choose ".023" from the list. After I select it, I make the needed
changes and press the update button. At the end of the UpdateButton
Method, I have a line of code: cboTaxValue.Ite ms.Clear(). This line
removes all of the items in the ComboBox except for the item I had
previously selected. I have also tried cboTaxValue.Sel ectedText =
String.Empty, that does not clear the item selected in the ComboBox
either.

Puzzled and confused I am.

I hope this was enough explanation, appreciate any help.

Scott Moore
Oct 4 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
7477
by: Wayne Wengert | last post by:
I am trying to populate a combobox with a lisy of items. I want the 1st item to be "Make a Selection" and the following items will be names from a table in my DB (See code below). When I run the project, the combox box initially displays an empty selection. When I click on the drop down arrow I see the "Make a Selection" followed by the...
0
630
by: stingrays | last post by:
Below is my code for a combobox. Basically, I have 2 comboboxes. 1 box is the application selection and the other retrieves data from the dataset (SQL Server) to populate the drop down in the otehr box. I want to make a selection in the app combobox, update the second box and when I select a new app, it should remove all items in teh 2nd...
1
5340
by: Geir Sanne | last post by:
hi!!! is it possible to set the backcolor to red of the items in a combobox and make the combo itself be white as it is default ? when i set combobox.backcolor i set both combox backcolor and combobox items backcolor. -Geir
1
4544
by: mdb | last post by:
I currently catch the SelectedIndexChanged event on a ComboBox to perform some processing when the user changes the selected item. But I also want to know when the user clears the list, but I can't seem to catch any events that would indicate when this is happening. I've tried SelectedIndexChanged, SelectedValueChanged, TextChanged. What...
1
1504
by: Rob R. Ainscough | last post by:
What I'm trying to accomplish is: Disable a ComboBox (not bound to any data) when a .Clear method is executed. So far a cboComboBox.Items.Clear does NOT trigger any of the events I expected it would. I've placed break points in the following events and still they are not triggered: Click SelectedValueChange
21
5178
by: StriderBob | last post by:
Situation : FormX is mdi child form containing 2 ListViews ListView1 contains a list of table names and 4 sub items with data about each table. ListView2 contains a list of the columns on each table and 11 sub items with data about each column. When a Row in ListView1 is selected the Data in ListVies2 is loaded to show the correct data....
5
1527
by: TS | last post by:
This is getting very frustrating. I placed the same question before twice and got no response. Hopefully I'll get one this time. What I want to do is to restrict the items in one of the cbo boxes in my windows form based on what is selected in another cbo box. Example: When I choose "George" from the cbo box that shows the clients last names,...
2
1309
by: elwaly | last post by:
Hi evry one, I want to build a group of comboboxs that have 3 to 6 items but initially i want them to start blank on run time, And show the first item when I press a command button i.e. Each combobox shows it's first item(0). thanks.
1
14671
by: JAnn81 | last post by:
I have a combo box created using xaml. I bind the item source to a xml document. <Items> <Item> <Name>David</Name> <Age>20</Age> </Item> <Item> <Name>Marcus</Name> <Age>25</Age>
0
7473
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7408
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...
1
7433
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...
0
5976
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5340
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4949
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...
0
3458
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...
1
1891
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
712
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...

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.