1、设置需要接受拖动事件的控件的AllowDrop属性为True,在开发界面时配置,不可通过代码配置
2、在DragEnter事件处理程序里,为e.Effet设置枚举值,否则拖动无效
Private Sub GroupBox1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles GroupBox1.DragEnter
e.Effect = DragDropEffects.Link
End Sub
3、在DragDrop事件中处理拖入的内容
Private Sub GroupBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles GroupBox1.DragDrop
s = e.Data.GetData(System.Windows.Forms.DataFormats.FileDrop)
Me.Text = "File Pro - 正在移动文件"
End Sub
4、获取拖入的内容
s = e.Data.GetData(System.Windows.Forms.DataFormats.FileDrop)