Results 1 to 2 of 2

Thread: Listbox Column Move

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2004
    Posts
    18

    Listbox Column Move

    Hello

    **Confused**

    I have 2 multiple column listbox's (listbox1 & 2). I am using a select/drag/drop function to move from listbox 1 to 2. I am attempting to move the selected line (3 columns) of the listbox. Both are set to 3 colums. How do I grab all three columns?

    VB Code:
    1. Private Sub ListBox2_BeforeDropOrPaste(ByVal Cancel As _
    2. MSForms.ReturnBoolean, _
    3. ByVal Action As Long, _
    4. ByVal Data As MSForms.DataObject, _
    5. ByVal X As Single, _
    6. ByVal Y As Single, _
    7. ByVal Effect As MSForms.ReturnEffect, _
    8. ByVal Shift As Integer)
    9.  
    10. Cancel = True
    11. Effect = fmDropEffectMove
    12. Dim I
    13. With ListBox1
    14.     For I = 0 To .ListCount - 1
    15.         If .Selected(I) Then
    16.        
    17.         ListBox2.AddItem .List(I)                        <----only 1st item?
    18.     End If
    19. Next
    20. End With

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: Listbox Column Move

    Your first column is likely to be the Key ID column. So that is what is added.
    To get to the other columns usually you need:
    Code:
    lstBox.column(0,1) 'first column, first row (data if you have title row)
    lstBox.column(1,1) 'second column
    lstBox.column(2,1) 'third column
    May be slightly different in VB coding, but that should help.
    I think it is in the help files/intellisense.

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

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