Imports Microsoft.Office.Interop.Excel
Imports Microsoft.Office.Interop
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ListBox1.AllowDrop = True
End Sub
Private Sub ListBox1_DragDrop(sender As Object, e As DragEventArgs) Handles ListBox1.DragDrop
For Each item As String In e.Data.GetData(DataFormats.FileDrop)
ListBox1.Items.Add(item)
Next
End Sub
Private Sub ListBox1_DragEnter(sender As Object, e As DragEventArgs) Handles ListBox1.DragEnter
e.Effect = DragDropEffects.Copy
End Sub
Private Sub Copyfullname_Click(sender As Object, e As EventArgs) Handles Copyfullname.Click
Dim cc As String
For Each item As String In ListBox1.Items
cc = cc & item & vbCrLf
Next
' MsgBox(cc)
Clipboard.Clear()
Clipboard.SetText(cc)
End Sub
Private Sub copyname_Click(sender As Object, e As EventArgs) Handles copyname.Click
Dim cc As String
For Each item As String In ListBox1.Items
cc = cc & IO.Path.GetFileNameWithoutExtension(item) & vbCrLf
Next
' MsgBox(cc)
Clipboard.Clear()
Clipboard.SetText(cc)
End Sub
End Class
vb拖放实现
最新推荐文章于 2024-04-23 16:46:35 发布