【问题标题】:VB.NET Check for keydown on dragdropVB.NET 在拖放时检查 keydown
【发布时间】:2020-10-23 15:58:22
【问题描述】:

我已经尝试了相当多的搜索来寻找这个答案,但未能找到一个好的解决方案。

我的表单上有一个 datagridview,用户可以在其中将文件拖放到网格上并填写某些列。这很好用。

我希望能够检查用户在删除文件时是否按下了某个键。如果是这样,我想用它来将特定数据添加到数据网格中的列之一。

这可能吗?

编辑:

我之前在拖放之外使用过 keydown,但似乎我遗漏了一些东西。我的代码如下。不管我做什么,我从来没有得到“T is press”,但我总是得到“T is not press”。

Private Sub frmReader_DragDrop(sender As Object, e As DragEventArgs) Handles Me.DragDrop
    Dim files As String() = CType(e.Data.GetData(DataFormats.FileDrop), String())
    If Keyboard.IsKeyDown(Keys.T) Then
        MsgBox("T is pressed.")
        ' Put certain info into the datagridview
    Else
        MsgBox("T is not pressed.")
        ' Put other data into the datagridview
    End If
End Sub

【问题讨论】:

标签: vb.net drag-and-drop keypress keydown


【解决方案1】:

上帝,尴尬...我将“Keys.T”更改为“Key.T”,它工作正常。打扰了。

【讨论】:

    猜你喜欢
    • 2011-05-21
    • 2011-09-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-26
    • 2012-04-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多