clearing a combo box...

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

    clearing a combo box...

    I have something strange going on - pretty sure it used to work before - and
    now it does not...

    Why does the following code not clear a combo box?

    Me.cboLocation. Text = String.Empty

    OR

    Me.cboLocation. Text = ""

    Neither of the above works. The combo box contents remain exactly the same
    after running that command...



    Help!



    Thanks, Brad


  • zacks@construction-imaging.com

    #2
    Re: clearing a combo box...

    On May 7, 1:17 pm, "Brad Pears" <br...@truenort hloghomes.comwr ote:
    I have something strange going on - pretty sure it used to work before - and
    now it does not...
    >
    Why does the following code not clear a combo box?
    >
    Me.cboLocation. Text = String.Empty
    >
    OR
    >
    Me.cboLocation. Text = ""
    >
    Neither of the above works.  The combo box contents remain exactly the same
    after running that command...
    >
    Help!
    >
    Thanks, Brad
    I think you will also need to set the .SelectedIndex property to -1.

    At least, that works for me.

    Comment

    • Armin Zingler

      #3
      Re: clearing a combo box...

      "Brad Pears" <bradp@truenort hloghomes.comsc hrieb
      I have something strange going on - pretty sure it used to work
      before - and now it does not...
      >
      Why does the following code not clear a combo box?
      >
      Me.cboLocation. Text = String.Empty
      >
      OR
      >
      Me.cboLocation. Text = ""
      >
      Neither of the above works. The combo box contents remain exactly
      the same after running that command...
      What's the value of cboLocation.Dro pdownstyle? If it's "DropDownLi st",
      use cboLocation.Sel ectedIndex = -1


      Armin

      Comment

      • kimiraikkonen

        #4
        Re: clearing a combo box...

        On May 7, 8:17 pm, "Brad Pears" <br...@truenort hloghomes.comwr ote:
        I have something strange going on - pretty sure it used to work before - and
        now it does not...
        >
        Why does the following code not clear a combo box?
        >
        Me.cboLocation. Text = String.Empty
        >
        OR
        >
        Me.cboLocation. Text = ""
        >
        Neither of the above works. The combo box contents remain exactly the same
        after running that command...
        >
        Help!
        >
        Thanks, Brad
        Hi,
        Using DropDownList style it doesn't clear combobox, Simple or DropDown
        styles allow you to clear with the codes you've mentioned.

        And if you want to clear current item of your combobox(curren t item,
        because "clear" term may come to meaning of clearing entire combobox
        which you did not intend to do), you can use
        "Me.cboLocation .selectedindex = - 1" or add a empty item temporarily
        using:

        Me.cboLocation. Items.Add("")
        Me.cboLocation. Text = ""
        Me.cboLocation. Items.Remove("" )

        Hope these help,

        Onur

        Comment

        • Brad Pears

          #5
          Re: clearing a combo box...

          Thanks for your reply's... That works perfect.... I had changed the type of
          drop down and that is why my previous code no longer worked. I knew there
          had to be an explanation somewhere!!!

          Thanks, again, Brad

          "Brad Pears" <bradp@truenort hloghomes.comwr ote in message
          news:uKxIJZGsIH A.1236@TK2MSFTN GP02.phx.gbl...
          >I have something strange going on - pretty sure it used to work before -
          >and now it does not...
          >
          Why does the following code not clear a combo box?
          >
          Me.cboLocation. Text = String.Empty
          >
          OR
          >
          Me.cboLocation. Text = ""
          >
          Neither of the above works. The combo box contents remain exactly the
          same after running that command...
          >
          >
          >
          Help!
          >
          >
          >
          Thanks, Brad
          >
          >

          Comment

          • Brad Pears

            #6
            Setting a value in a combo box to a listview item's text value

            I am trying to set a combo box's text property to a value from a listview
            item's text property as shown below... However, it appears that because the
            combo box is defined as a "DropDownLi st", am I am now unable to assign a
            text value that way? Do I now have to find out what position the listview
            item's text value I want is in the list of combo items and then assign an
            index value instead of an actual text value? (Wow, that was a mouthful!!!)

            Me.cboLabel.Tex t = Me.lvwJobPosts. SelectedItems.I tem(0).SubItems (2).Text
            Thanks, Brad



            "kimiraikko nen" <kimiraikkonen8 5@gmail.comwrot e in message
            news:60cc6359-2304-4278-8cf1-b083def26e00@m4 4g2000hsc.googl egroups.com...
            On May 7, 8:17 pm, "Brad Pears" <br...@truenort hloghomes.comwr ote:
            >I have something strange going on - pretty sure it used to work before -
            >and
            >now it does not...
            >>
            >Why does the following code not clear a combo box?
            >>
            >Me.cboLocation .Text = String.Empty
            >>
            >OR
            >>
            >Me.cboLocation .Text = ""
            >>
            >Neither of the above works. The combo box contents remain exactly the
            >same
            >after running that command...
            >>
            >Help!
            >>
            >Thanks, Brad
            >
            Hi,
            Using DropDownList style it doesn't clear combobox, Simple or DropDown
            styles allow you to clear with the codes you've mentioned.
            >
            And if you want to clear current item of your combobox(curren t item,
            because "clear" term may come to meaning of clearing entire combobox
            which you did not intend to do), you can use
            "Me.cboLocation .selectedindex = - 1" or add a empty item temporarily
            using:
            >
            Me.cboLocation. Items.Add("")
            Me.cboLocation. Text = ""
            Me.cboLocation. Items.Remove("" )
            >
            Hope these help,
            >
            Onur

            Comment

            • kimiraikkonen

              #7
              Re: Setting a value in a combo box to a listview item's text value

              On May 7, 11:20 pm, "Brad Pears" <br...@truenort hloghomes.comwr ote:
              I am trying to set a combo box's text property to a value from a listview
              item's text property as shown below... However, it appears that because the
              combo box is defined as a "DropDownLi st", am I am now unable to assign a
              text value that way? Do I now have to find out what position the listview
              item's text value I want is in the list of combo items and then assign an
              index value instead of an actual text value? (Wow, that was a mouthful!!!)
              >
              Me.cboLabel.Tex t = Me.lvwJobPosts. SelectedItems.I tem(0).SubItems (2).Text
              Thanks, Brad
              >
              "kimiraikko nen" <kimiraikkone.. .@gmail.comwrot e in message
              >
              news:60cc6359-2304-4278-8cf1-b083def26e00@m4 4g2000hsc.googl egroups.com...
              >
              On May 7, 8:17 pm, "Brad Pears" <br...@truenort hloghomes.comwr ote:
              I have something strange going on - pretty sure it used to work before -
              and
              now it does not...
              >
              Why does the following code not clear a combo box?
              >
              Me.cboLocation. Text = String.Empty
              >
              OR
              >
              Me.cboLocation. Text = ""
              >
              Neither of the above works. The combo box contents remain exactly the
              same
              after running that command...
              >
              Help!
              >
              Thanks, Brad
              >
              Hi,
              Using DropDownList style it doesn't clear combobox, Simple or DropDown
              styles allow you to clear with the codes you've mentioned.
              >
              And if you want to clear current item of your combobox(curren t item,
              because "clear" term may come to meaning of clearing entire combobox
              which you did not intend to do), you can use
              "Me.cboLocation .selectedindex = - 1" or add a empty item temporarily
              using:
              >
              Me.cboLocation. Items.Add("")
              Me.cboLocation. Text = ""
              Me.cboLocation. Items.Remove("" )
              >
              Hope these help,
              >
              Onur
              Hi,
              I really had difficulty to make out what you're trying to do, as a
              little understanding, if you want to syncronize two values between a
              listview's subitem and combobox, you can do it with the code that you
              posted.

              Me.cboLabel.Tex t =
              Me.lvwJobPosts. SelectedItems.I tem(0).SubItems (2).Text

              I think you're asking if you have to specify index of listview
              subitem's and i think yes you have to. If you used listbox instead of
              listview you could use listbox1.select editem to get items text
              property without specifying index (position) name.

              Thanks,

              Onur Güzel

              Comment

              • Brad Pears

                #8
                Re: Setting a value in a combo box to a listview item's text value

                Thanks for the reply... Yes, actually the code that I posted was actually
                working as I discovered later on through more debugging. There was a
                different problem that was setting the listview item index to -1 so it
                appeared that my code was not setting the value at all when in fact it was.
                Thanks for your help.

                Brad
                "kimiraikko nen" <kimiraikkonen8 5@gmail.comwrot e in message
                news:99555820-b512-4163-900b-abe2440119d6@e5 3g2000hsa.googl egroups.com...
                On May 7, 11:20 pm, "Brad Pears" <br...@truenort hloghomes.comwr ote:
                I am trying to set a combo box's text property to a value from a listview
                item's text property as shown below... However, it appears that because
                the
                combo box is defined as a "DropDownLi st", am I am now unable to assign a
                text value that way? Do I now have to find out what position the listview
                item's text value I want is in the list of combo items and then assign an
                index value instead of an actual text value? (Wow, that was a mouthful!!!)
                >
                Me.cboLabel.Tex t = Me.lvwJobPosts. SelectedItems.I tem(0).SubItems (2).Text
                Thanks, Brad
                >
                "kimiraikko nen" <kimiraikkone.. .@gmail.comwrot e in message
                >
                news:60cc6359-2304-4278-8cf1-b083def26e00@m4 4g2000hsc.googl egroups.com...
                >
                On May 7, 8:17 pm, "Brad Pears" <br...@truenort hloghomes.comwr ote:
                I have something strange going on - pretty sure it used to work
                before -
                and
                now it does not...
                >
                Why does the following code not clear a combo box?
                >
                Me.cboLocation. Text = String.Empty
                >
                OR
                >
                Me.cboLocation. Text = ""
                >
                Neither of the above works. The combo box contents remain exactly the
                same
                after running that command...
                >
                Help!
                >
                Thanks, Brad
                >
                Hi,
                Using DropDownList style it doesn't clear combobox, Simple or DropDown
                styles allow you to clear with the codes you've mentioned.
                >
                And if you want to clear current item of your combobox(curren t item,
                because "clear" term may come to meaning of clearing entire combobox
                which you did not intend to do), you can use
                "Me.cboLocation .selectedindex = - 1" or add a empty item temporarily
                using:
                >
                Me.cboLocation. Items.Add("")
                Me.cboLocation. Text = ""
                Me.cboLocation. Items.Remove("" )
                >
                Hope these help,
                >
                Onur
                Hi,
                I really had difficulty to make out what you're trying to do, as a
                little understanding, if you want to syncronize two values between a
                listview's subitem and combobox, you can do it with the code that you
                posted.

                Me.cboLabel.Tex t =
                Me.lvwJobPosts. SelectedItems.I tem(0).SubItems (2).Text

                I think you're asking if you have to specify index of listview
                subitem's and i think yes you have to. If you used listbox instead of
                listview you could use listbox1.select editem to get items text
                property without specifying index (position) name.

                Thanks,

                Onur Güzel


                Comment

                Working...