取消VB .Net中的Keypress无效

时间:2017-05-29 02:09:07

标签: vb.net keyboard-shortcuts

我想在VB .Net中的富文本框中捕获keydown事件。

根据我看到的文档和示例,我只需要使用e.Handled = True但这不起作用,我仍然将密钥值放在富文本框中。

我的代码是

    Private Sub Tagging_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles rtxReference.KeyDown
    If ((e.KeyCode = Keys.Z) AndAlso e.Control) Then
        'MsgBox("Undo")
        rtxReference.Text = sPrevious
    Else
        If cbxHotKeyTags.Checked Then
            If e.KeyCode = Keys.T Then
                sTagName = "article-title"
            ElseIf e.KeyCode = Keys.V Then
                sTagName = "volume"
            ElseIf e.KeyCode = Keys.F Then
                sTagName = "fpage"
            ElseIf e.KeyCode = Keys.L Then
                sTagName = "lpage"
            ElseIf e.KeyCode = Keys.I Then
                sTagName = "issuee"
            End If
            e.Handled = True
        End If

    End If
End Sub

0 个答案:

没有答案