请教一下VB.NET WinForm 中,可不可以做到用户在Excel中选择一列值,然后复制,可以直接粘贴在VB.NET中的ListBox框中吗?谢谢!
------解决方案--------------------
Private Sub ListBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ListBox1.KeyDown
If e.KeyCode = Keys.V And e.Control Then
e.SuppressKeyPress = True
ListBox1.Items.Add(Clipboard.GetText)
End If
End Sub
运行程序后,
在Excel表中选中要复制的域,Ctrl+C
选中ListBox1域,Ctrl+V
------解决方案--------------------
在Excel表中选中要复制的单元格,鼠标左键点复制,直接点listbox1,就复制进来了
Private Sub ListBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown
If e.Clicks Then
ListBox1.Items.Add(Clipboard.GetText)
End If
End Sub