VB Drag & Drop Files

From this question on Stack Overflow.

 

 

Imports System.Windows.Forms
 
Public Class Form1
 
    Private Sub TextBox1_DragEnter(ByVal sender As Object, ByVal e As DragEventArgs) Handles TextBox1.DragEnter
        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
            e.Effect = DragDropEffects.All
        End If
    End Sub
 
    Private Sub TextBox1_DragDrop(ByVal sender As Object, ByVal e As DragEventArgs) Handles TextBox1.DragDrop
        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
            Dim MyFiles() As String
            Dim i As Integer
            MyFiles = e.Data.GetData(DataFormats.FileDrop)
            TextBox1.Text = MyFiles(i)
        End If
    End Sub
 
End Class
AttachmentSize
FileDragDrop.zip64.64 KB
Your rating: None Average: 5 (2 votes)

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
 
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <csharp>, <css>, <drupal5>, <drupal6>, <java>, <javascript>, <objc>, <php>, <python>, <ruby>, <tsql>. The supported tag styles are: <foo>, [foo].

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.