|
-
Jan 12th, 2004, 10:49 AM
#1
Thread Starter
New Member
Drag and Drop files from Explorer
Hi
How to drag and drop one or more selected files from Windows Explorer in Listbox, i mean only the filename
-
Jan 13th, 2004, 08:08 AM
#2
New Member
1) Put in your form a Listbox
2)In listbox properties change AlloDrop=True and Name=Listbox
3) Just copy&paste the code
Private Sub ListBox_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox.DragEnter
If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then
e.Effect = DragDropEffects.All
Else
e.Effect = DragDropEffects.None
End If
End Sub
Private Sub ListBox_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox.DragDrop
Dim DropContents() As String
Dim FileName As String
Try
DropContents = e.Data.GetData(DataFormats.FileDrop, True)
FileName = DropContents(0)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
If FileName <> "" And IO.File.Exists(FileName) = True Then
Dim lstFiles As ListViewItem = New ListViewItem()
lstFiles.Text = (FileName)
ListBox.Items.Add(FileName)
lstFiles = Nothing
End If
End Sub
Things go better with rock
-
Jan 14th, 2004, 11:07 AM
#3
Thread Starter
New Member
That works
Thanks DigitalHand
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|