DoDragDrop

bjwade62

Well-known member
Joined
May 25, 2006
Messages
50
Programming Experience
3-5
I want to drag an item in a listbox (that represents a file) into another application. The drop is the easy part since the other application receives dropped files. How do I get started? I've tried the mousemove\DoDragDrop event with no luck.

Can anyone help me? Thanks,
Bernie
 
The DataObject is a string array of fully qualified file (and/or folder) paths, its type is FileDrop. Here is an example, I'm not taking any item from the listbox, just one test file, you figure out what items this regards.
VB.NET:
Private Sub ListBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles ListBox1.MouseDown
    Dim files(0) As String
    files(0) = IO.Path.Combine(Application.StartupPath, "pr.txt")
    Dim ido As New DataObject(DataFormats.FileDrop, files)
    Me.DoDragDrop(ido, DragDropEffects.All)
End Sub
 
Back
Top