Drag and drop
Posted: Fri Apr 30, 2010 4:27 pm
Hello, i wanted to know how to drag and drop an item and listbox shows dropped file name(not the path, only name). Thanks.
Sharing, Teaching and Supporting coders of all ages and levels since 2009
https://www.codenstuff.com/forum/
Private Sub ListBox1_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox1.DragEnter
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
e.Effect = DragDropEffects.Copy
End If
End Sub
Private Sub ListBox1_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox1.DragDrop
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
Dim draggedFiles As String() = CType(e.Data.GetData(DataFormats.FileDrop), String())
For Each filename As String In draggedFiles
ListBox1.Items.Add(FileIO.FileSystem.GetFileInfo(filename).Name)
Next
End If
End Sub