listboxes to select/deselect multiple items

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

    listboxes to select/deselect multiple items

    I would like to be able to do the following:

    Listbox1/Textbox1 contains list of all items not selected

    item A
    item B
    item D

    Listbox2//Textbox2 contains list of all items selected

    item C
    item E

    User then can highlight desired items to select/deselect using the
    corresponding arrows (or the like).

    Any sample/tip is greatly appreciated.

    Bill


  • Terry Burns

    #2
    Re: listboxes to select/deselect multiple items

    There are usually several ways, here is one which uses the
    SelectedIndexCh amnged Event of the source Listbox. In my Example, I have
    named them lb1 and lb2 ( source and destination respectively )

    Private Sub lb1_SelectedInd exChanged(ByVal sender As System.Object, ByVal e
    As System.EventArg s) Handles lb1.SelectedInd exChanged

    Dim o As Object

    Dim senderBox As ListBox

    senderBox = DirectCast(send er, ListBox)

    lb2.Items.Clear ()

    For Each o In senderBox.Selec tedItems

    lb2.Items.Add(o )

    Next

    End Sub

    -
    Terry Burns







    "Bill Nguyen" <billn_nospam_p lease@jaco.com> wrote in message
    news:%23MeB0BIM FHA.568@TK2MSFT NGP09.phx.gbl.. .[color=blue]
    >I would like to be able to do the following:
    >
    > Listbox1/Textbox1 contains list of all items not selected
    >
    > item A
    > item B
    > item D
    >
    > Listbox2//Textbox2 contains list of all items selected
    >
    > item C
    > item E
    >
    > User then can highlight desired items to select/deselect using the
    > corresponding arrows (or the like).
    >
    > Any sample/tip is greatly appreciated.
    >
    > Bill
    >[/color]


    Comment

    • Bill Nguyen

      #3
      Re: listboxes to select/deselect multiple items

      Thanks Terry;
      I'll try this.
      Bill

      "Terry Burns" <us@ourWebSite. com> wrote in message
      news:%23%23ZA1E JMFHA.3420@tk2m sftngp13.phx.gb l...[color=blue]
      > There are usually several ways, here is one which uses the
      > SelectedIndexCh amnged Event of the source Listbox. In my Example, I have
      > named them lb1 and lb2 ( source and destination respectively )
      >
      > Private Sub lb1_SelectedInd exChanged(ByVal sender As System.Object, ByVal
      > e As System.EventArg s) Handles lb1.SelectedInd exChanged
      >
      > Dim o As Object
      >
      > Dim senderBox As ListBox
      >
      > senderBox = DirectCast(send er, ListBox)
      >
      > lb2.Items.Clear ()
      >
      > For Each o In senderBox.Selec tedItems
      >
      > lb2.Items.Add(o )
      >
      > Next
      >
      > End Sub
      >
      > -
      > Terry Burns
      > http://TrainingOn.net
      >
      >
      >
      >
      >
      >
      > "Bill Nguyen" <billn_nospam_p lease@jaco.com> wrote in message
      > news:%23MeB0BIM FHA.568@TK2MSFT NGP09.phx.gbl.. .[color=green]
      >>I would like to be able to do the following:
      >>
      >> Listbox1/Textbox1 contains list of all items not selected
      >>
      >> item A
      >> item B
      >> item D
      >>
      >> Listbox2//Textbox2 contains list of all items selected
      >>
      >> item C
      >> item E
      >>
      >> User then can highlight desired items to select/deselect using the
      >> corresponding arrows (or the like).
      >>
      >> Any sample/tip is greatly appreciated.
      >>
      >> Bill
      >>[/color]
      >
      >[/color]


      Comment

      • Bill Nguyen

        #4
        Re: listboxes to select/deselect multiple items


        Terry;
        I would like to remove the selected items from senderBox once they moved to
        lb2 in your example. I can seem to make it work I tried to use
        ..Items.Remove( .selectedindex) but the items remain in the senderBox.

        Please help!

        Thanks
        Bill

        "Terry Burns" <us@ourWebSite. com> wrote in message
        news:%23%23ZA1E JMFHA.3420@tk2m sftngp13.phx.gb l...[color=blue]
        > There are usually several ways, here is one which uses the
        > SelectedIndexCh amnged Event of the source Listbox. In my Example, I have
        > named them lb1 and lb2 ( source and destination respectively )
        >
        > Private Sub lb1_SelectedInd exChanged(ByVal sender As System.Object, ByVal
        > e As System.EventArg s) Handles lb1.SelectedInd exChanged
        >
        > Dim o As Object
        >
        > Dim senderBox As ListBox
        >
        > senderBox = DirectCast(send er, ListBox)
        >
        > lb2.Items.Clear ()
        >
        > For Each o In senderBox.Selec tedItems
        >
        > lb2.Items.Add(o )
        >
        > Next
        >
        > End Sub
        >
        > -
        > Terry Burns
        > http://TrainingOn.net
        >
        >
        >
        >
        >
        >
        > "Bill Nguyen" <billn_nospam_p lease@jaco.com> wrote in message
        > news:%23MeB0BIM FHA.568@TK2MSFT NGP09.phx.gbl.. .[color=green]
        >>I would like to be able to do the following:
        >>
        >> Listbox1/Textbox1 contains list of all items not selected
        >>
        >> item A
        >> item B
        >> item D
        >>
        >> Listbox2//Textbox2 contains list of all items selected
        >>
        >> item C
        >> item E
        >>
        >> User then can highlight desired items to select/deselect using the
        >> corresponding arrows (or the like).
        >>
        >> Any sample/tip is greatly appreciated.
        >>
        >> Bill
        >>[/color]
        >
        >[/color]


        Comment

        • OHM \( Terry Burns \)

          #5
          Re: listboxes to select/deselect multiple items

          Is the sender box bound to a dataset or other object ?
          --
          OHM ( Terry Burns )



          "Bill Nguyen" <billn_nospam_p lease@jaco.com> wrote in message
          news:%234yFzwuO FHA.3408@TK2MSF TNGP14.phx.gbl. ..[color=blue]
          >
          > Terry;
          > I would like to remove the selected items from senderBox once they moved
          > to lb2 in your example. I can seem to make it work I tried to use
          > .Items.Remove(. selectedindex) but the items remain in the senderBox.
          >
          > Please help!
          >
          > Thanks
          > Bill
          >
          > "Terry Burns" <us@ourWebSite. com> wrote in message
          > news:%23%23ZA1E JMFHA.3420@tk2m sftngp13.phx.gb l...[color=green]
          >> There are usually several ways, here is one which uses the
          >> SelectedIndexCh amnged Event of the source Listbox. In my Example, I have
          >> named them lb1 and lb2 ( source and destination respectively )
          >>
          >> Private Sub lb1_SelectedInd exChanged(ByVal sender As System.Object, ByVal
          >> e As System.EventArg s) Handles lb1.SelectedInd exChanged
          >>
          >> Dim o As Object
          >>
          >> Dim senderBox As ListBox
          >>
          >> senderBox = DirectCast(send er, ListBox)
          >>
          >> lb2.Items.Clear ()
          >>
          >> For Each o In senderBox.Selec tedItems
          >>
          >> lb2.Items.Add(o )
          >>
          >> Next
          >>
          >> End Sub
          >>
          >> -
          >> Terry Burns
          >> http://TrainingOn.net
          >>
          >>
          >>
          >>
          >>
          >>
          >> "Bill Nguyen" <billn_nospam_p lease@jaco.com> wrote in message
          >> news:%23MeB0BIM FHA.568@TK2MSFT NGP09.phx.gbl.. .[color=darkred]
          >>>I would like to be able to do the following:
          >>>
          >>> Listbox1/Textbox1 contains list of all items not selected
          >>>
          >>> item A
          >>> item B
          >>> item D
          >>>
          >>> Listbox2//Textbox2 contains list of all items selected
          >>>
          >>> item C
          >>> item E
          >>>
          >>> User then can highlight desired items to select/deselect using the
          >>> corresponding arrows (or the like).
          >>>
          >>> Any sample/tip is greatly appreciated.
          >>>
          >>> Bill
          >>>[/color]
          >>
          >>[/color]
          >
          >[/color]


          Comment

          Working...