Results 1 to 3 of 3

Thread: Drag and Drop files from Explorer

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2004
    Posts
    5

    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
    Yo mamma Osama...

  2. #2
    New Member
    Join Date
    Dec 2003
    Posts
    12
    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

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2004
    Posts
    5
    That works
    Thanks DigitalHand
    Yo mamma Osama...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width