Results 1 to 3 of 3

Thread: Drag & Drop with List View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 1999
    Location
    México, D.F.
    Posts
    84

    Post

    Hi everybody!!!

    Does anybody know how can i made drag & drop with list view? I have problems to select an item while begin the drag function.

    Thanks in advance!!!
    I appreciate your help.

    ------------------
    Angel Maldonado López.
    Programmer
    [email protected]

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    Add a Listbox and ListView Control to a Form, then Paste this quick Example I have put together..
    Code:
    Private Sub Form_Load()
        Dim I As Integer
        ListView1.View = lvwList
        ListView1.MultiSelect = True
        ListView1.DragIcon = LoadPicture("..\Common\Graphics\Icons\DragDrop\Drag3pg.ico")
        For I = 1 To 100
            ListView1.ListItems.Add , , "Item " & I
        Next
    End Sub
    
    Private Sub List1_DragDrop(Source As Control, x As Single, y As Single)
        Dim I As Integer
        If TypeName(Source) <> "ListView" Then Exit Sub
        With Source
            For I = 1 To .ListItems.Count
                If .ListItems(I).Selected Then List1.AddItem .ListItems(I)
            Next
        End With
    End Sub
    
    Private Sub ListView1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
        If Button = vbLeftButton Then
            ListView1.Drag vbBeginDrag
        Else
            ListView1.Drag vbEndDrag
        End If
    End Sub

    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 1999
    Location
    México, D.F.
    Posts
    84

    Post

    Yeah!!!
    It works perfect...
    Thank you very much Aaron, you have saved my program...
    Thanks again...

    ------------------
    Angel Maldonado López.
    Programmer
    [email protected]

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