VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > VB.net教程 >
  • VB.NET笔记 实现文件拖拽到窗体

 
Private Sub Form1_Load( ByVal sender As System.Object, ByVal e As System. EventArgs) Handles MyBase.Load
Me. AllowDrop = True
End Sub
''建拖曳事件,实现文件拖放
Private Sub Form1_DragEnter( ByVal sender As Object, ByVal e As System.Windows.Forms. DragEventArgs) Handles Me.DragEnter
Try
If e.Data. GetDataPresent(DataFormats. FileDrop) = True Then
e. Effect = DragDropEffects.Copy
Else
e. Effect = DragDropEffects.None
End If
Catch ex As Exception
MessageBox. Show(ex. Message)
End Try
End Sub
Private Sub Form1_DragDrop( ByVal sender As Object, ByVal e As System.Windows.Forms. DragEventArgs) Handles Me.DragEnter
Try
Dim filepath As String() = e.Data. GetData(DataFormats. FileDrop)
For Each File As String In filepath
textBox1. Text = File
Next
'textBox1.text=filepath(0) 这里还可以这样实现
Catch ex As Exception
MessageBox. Show(ex. Message)
End Try
End Sub


相关教程