Results 1 to 8 of 8

Thread: [RESOLVED] Select same item in two ListBoxes simultaneously

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Resolved [RESOLVED] Select same item in two ListBoxes simultaneously

    Hi, I have two ListBoxes with exactly the same items.
    If I click on an item in ListBox 1 and highlight it, can also the exact same item in ListBox 2 be selected/highlighted at the same time?

    Thanks.

  2. #2
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Select same item in two ListBoxes simultaneously

    is it in the same position? If so,
    VB Code:
    1. Private Sub List1_Click()
    2.     List2.ListIndex = List1.ListIndex
    3. End Sub

  3. #3

  4. #4
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Select same item in two ListBoxes simultaneously

    Quote Originally Posted by bushmobile
    is it in the same position? If so,
    VB Code:
    1. Private Sub List1_Click()
    2.     List2.ListIndex = List1.ListIndex
    3. End Sub
    If items are not in the same position then that will not work (if one list is sorted and second is not OR both lists were populated in some random order).
    Best way to search second list for matching item and then highlight it. Forum has plenty of samples.

  5. #5
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Select same item in two ListBoxes simultaneously

    i did ask "is it in the same position" - if it is then that's the easiest way, if not then sure you'll have to search the list.

  6. #6

  7. #7
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Select same item in two ListBoxes simultaneously

    you edited your post! Now mine looks silly.

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: Select same item in two ListBoxes simultaneously

    Thank you bushmobile. I already tried that before and now I see I had put it in the wrong part of the MouseDown event...

    Everything is working fine now


    MartinLiss, I'm using a TabStrip with hiding/showing various Frames, so both ListBoxes in the Frames are not visible at the same time. The first Listbox is used to drop files into and the second one is later used to work with the files. When an item is deleted from ListBox1 or moved up/down, then the same thing has to happen in ListBox2. That's why I'm using two ListBoxes instead of a Listview.

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