469,616 Members | 1,823 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,616 developers. It's quick & easy.

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 17479
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Wayne Wengert | last post: by
reply views Thread by stingrays | last post: by
1 post views Thread by Geir Sanne | last post: by
1 post views Thread by mdb | last post: by
1 post views Thread by Rob R. Ainscough | last post: by
5 posts views Thread by TS | last post: by
2 posts views Thread by elwaly | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.