全局代码
Public Sub TextBox_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs)
Dim path As String = CType(e.Data.GetData(Windows.Forms.DataFormats.FileDrop), System.Array).GetValue(0).ToString()
sender.Text = path
sender.Cursor = System.Windows.Forms.Cursors.IBeam
End Sub
Public Sub TextBox_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 WinForm.TextBox = e.Form.Controls("TextBox1")
t.BaseControl.AllowDrop = True
AddHandler t.BaseControl.DragDrop, AddressOf TextBox_DragDrop
AddHandler t.BaseControl.DragEnter, AddressOf TextBox_DragEnter
[此贴子已经被作者于2015/10/3 22:00:57编辑过]