添加一个Listbox控件到窗体,将其AllowDrop属性设置为True。
Private Sub ListBox1_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox1.DragDrop
ListBox1.Items.Clear() '清理表
For Each s As String In e.Data.GetData(DataFormats.FileDrop) '循环枚举数据
ListBox1.Items.Add(s) '添加到表
Next
End Sub
Private Sub ListBox1_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox1.DragEnter
e.Effect = DragDropEffects.Link '拖放效果
End Sub