VB2005文件拖放到控件上

前端之家收集整理的这篇文章主要介绍了VB2005文件拖放到控件上前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
Public Class Form1
    Private Sub TextBox1_DragDrop(ByVal sender As System.Object,ByVal e As System.Windows.Forms.DragEventArgs) Handles TextBox1.DragDrop
        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
            Dim MyFiles() As String
            MyFiles = CType(e.Data.GetData(DataFormats.FileDrop),String())
            MsgBox(MyFiles(0))
        End If
    End Sub

    Private Sub TextBox1_DragEnter(ByVal sender As System.Object,ByVal e As System.Windows.Forms.DragEventArgs) Handles TextBox1.DragEnter
        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
            e.Effect = DragDropEffects.All
        End If
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles MyBase.Load
        TextBox1.AllowDrop = True
    End Sub
End Class
原文链接:https://www.f2er.com/vb/259745.html

猜你在找的VB相关文章