如何在表单中禁用esc键?

时间:2014-06-20 12:40:16

标签: vb.net devexpress-windows-ui

我有一个弹出窗口作为登录表单,但每当我按下esc键时,弹出按钮将退出,我不想要那样的事情,所以有没有在陷阱中捕获esc关键的东西?我测试了这些东西,但没有测试它们。

 Private Sub ItemAdd_FormClosed(sender As Object, e As FormClosedEventArgs) Handles Me.FormClosed
    If login = True Then
        MsgBox("haha")
    End If
End Sub

Private Sub ItemAdd_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
    If login = True Then
        MsgBox("haha")
    End If
End Sub

Private Sub ItemAdd_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
    If e.KeyCode = Keys.Space Then
        MsgBox("haha")

    End If
End Sub

或如何在表格中禁用ESC键?

1 个答案:

答案 0 :(得分:1)

我自己没有试过这个,但你试一试:

Private Sub ItemAdd_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown

  If e.KeyCode = Keys.Escape Then
    e.Handled = True
  End If

End Sub