-2

我有一个弹出窗口作为登录表单,但是每当我按下 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 键?

4

1 回答 1

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
于 2014-06-20T16:14:38.223 回答