Results 1 to 4 of 4

Thread: two list boxes

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2004
    Posts
    91

    two list boxes

    Hi,

    I have 2 list boxes side by side lets assume they are A and B, and A has list of names and when i select a name and click on the forward arrow it should appear in the B list box. Also when i again select a name from B and click the back arrow it should again appear in the A box.

    Can someone please help me in how to do this. I am a newbly and I am lost as to how to do it.

    Please help me.

    thanks

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    Set the form's KeyPreview property to True and then...

    VB Code:
    1. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    2.  
    3.     Select Case KeyCode
    4.         Case vbKeyRight
    5.             List2.AddItem List1.List(List1.ListIndex)
    6.             List1.RemoveItem List1.ListIndex
    7.         Case vbKeyLeft
    8.             List1.AddItem List2.List(List2.ListIndex)
    9.             List2.RemoveItem List2.ListIndex
    10.     End Select
    11. End Sub

  3. #3
    Frenzied Member ice_531's Avatar
    Join Date
    Aug 2002
    Location
    Sitting w/ Bob Status: -Next -To- Null- Friend: Philip
    Posts
    1,152
    well errr
    dun got vb out but im sure if you simply did sumthin like

    this shud work for goin from list1 to list2
    VB Code:
    1. Private Sub Command1_Click()
    2. Dim i As Integer
    3.  
    4. For i = List1.ListCount - 1 To 0 Step -1
    5. If List1.Selected(i) = True Then
    6. List2.AddItem List1.List(i)
    7. List1.RemoveItem i
    8. End If
    9. Next
    10. End Sub
    you should be able to edit that to remove and go back to list1


    ice
    :::`DISCLAIMER`:::
    Do NOT take anything i have posted to be truthful in any way, shape or form.
    Thank You!

    --------------------------------
    "Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe
    "Finaly I can look as gay as I want..." - NoteMe
    Languages: VB6, BASIC, Java, C#. C++

  4. #4
    Frenzied Member ice_531's Avatar
    Join Date
    Aug 2002
    Location
    Sitting w/ Bob Status: -Next -To- Null- Friend: Philip
    Posts
    1,152
    yes im bored.. i made a qwik sample for u

    does wut u wanted i believe..
    im attaching the form
    Attached Files Attached Files
    :::`DISCLAIMER`:::
    Do NOT take anything i have posted to be truthful in any way, shape or form.
    Thank You!

    --------------------------------
    "Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe
    "Finaly I can look as gay as I want..." - NoteMe
    Languages: VB6, BASIC, Java, C#. C++

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width