在keyPress事件中处理:
Private Sub frmMain_KeyPress(sender As Object, e As KeyPressEventArgs) Handles Me.KeyPress
If Asc(e.KeyChar) = 13 Or Asc(e.KeyChar) = 27 Then
e.Handled = True
End If
End Sub
本文介绍了一个简单的按键事件处理示例,展示了如何在VB.NET中使用KeyPress事件来捕捉并响应特定按键(如Enter键和Esc键)。通过设置e.Handled属性为True,可以阻止默认行为。
在keyPress事件中处理:
Private Sub frmMain_KeyPress(sender As Object, e As KeyPressEventArgs) Handles Me.KeyPress
If Asc(e.KeyChar) = 13 Or Asc(e.KeyChar) = 27 Then
e.Handled = True
End If
End Sub
4981
1021

被折叠的 条评论
为什么被折叠?
