473,396 Members | 2,002 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,396 software developers and data experts.

ComboBox.Items.Clear()

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

cboTaxValue.Item.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.Items.Clear(). This line
removes all of the items in the ComboBox except for the item I had
previously selected. I have also tried cboTaxValue.SelectedText =
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 17985
Use cboTaxValue.Text = 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.Item.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.Items.Clear(). This line
removes all of the items in the ComboBox except for the item I had
previously selected. I have also tried cboTaxValue.SelectedText =
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.SelectedIndex = -1
or
cboTaxValue.SelectedItem = 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.Item.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.Items.Clear(). This line
removes all of the items in the ComboBox except for the item I had
previously selected. I have also tried cboTaxValue.SelectedText =
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.Text = 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.Item.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.Items.Clear(). This line
removes all of the items in the ComboBox except for the item I had
previously selected. I have also tried cboTaxValue.SelectedText =
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
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...
0
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...
1
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...
1
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...
1
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...
21
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...
5
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...
2
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...
1
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
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...
0
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,...
0
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...
0
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...
0
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,...

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.