ComboBox.Items.Clear()

S

samoore33

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
 
K

Kelly Ethridge

You can use

cboTaxValue.SelectedIndex = -1
or
cboTaxValue.SelectedItem = Nothing

to unselect a selected item.

Kelly
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top