ComboBox.Items.Clear()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • samoore33

    #1

    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

  • rowe_newsgroups

    #2
    Re: ComboBox.Items. Clear()

    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

    Comment

    • Kelly Ethridge

      #3
      Re: ComboBox.Items. Clear()

      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
      >

      Comment

      • samoore33

        #4
        Re: ComboBox.Items. Clear()

        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

        Comment

        Working...