I wanted to initialize a drag from my program as a file... Kind of like Windows Explorer does. I found a way to do this on VB6 (see code below). But I'm not sure how to add this to my program in VB.NET. Currently I have it dragging a string containing the path to the file.
Here is the VB6 code:
Here is the VB6 code:
Code:
Private Sub Picture1_OLEStartDrag(Data As DataObject, AllowedEffects As Long)
' this evant allows us to implement dragging *from* our picturebox to other drag targets in the system
' make sure there is a file name in the tag property (you would probaby want to use a "file
' exists" routine here but for this demo we are doing it simply)
If Picture1.Tag <> "" Then
On Error GoTo EH
' set the drop effect to create a copy of the file wherever it get's dropped
AllowedEffects = vbDropEffectCopy
With Data
' clear the contents of the data object
.Clear
' tell the data object we will be dragging files
.SetData , vbCFFiles
' add the file name that we storred in the tag eairler
.Files.Add Picture1.Tag
End With
End If
ExitNow:
Exit Sub
EH:
Err.Clear
MsgBox "Unable to initiate drag."
Resume ExitNow
End Sub