'全局代码
Public Sub picture_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs)
Dim paths As object() = e.Data.GetData(Windows.Forms.DataFormats.FileDrop)
For Each path As object In paths
msgbox(path)
Next
sender.Cursor = System.Windows.Forms.Cursors.IBeam
End Sub
Public Sub picture_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs)
If (e.Data.GetDataPresent(Windows.Forms.DataFormats.FileDrop)) Then
e.Effect = Windows.Forms.DragDropEffects.Link
sender.Cursor = System.Windows.Forms.Cursors.Arrow
Else
e.Effect = Windows.Forms.DragDropEffects.None
End If
End Sub
'--------------------------------
窗口AfterLoad
Dim t As windows.Forms.panel = e.Form.Controls("panel1").basecontrol
t.AllowDrop = True
AddHandler t.DragDrop, AddressOf picture_DragDrop
AddHandler t.DragEnter, AddressOf picture_DragEnter