vb.net 按钮单击等于按键盘上的 Enter 键
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24261654/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Button Click Equals to Press Enter Key on the Keyboard
提问by Atakan
I would like to equal a click on Button1 to press the Enter key on the keyboard, how can I do that? Can you provide me the code please? Thanks in advance..
我想等于单击 Button1 以按键盘上的 Enter 键,我该怎么做?你能给我代码吗?提前致谢..
回答by Matt Wilko
Set the AcceptButtonproperty of your form to be Button1
将AcceptButton表单的属性设置为Button1
回答by Visual Vincent
I belive this is what he's looking for:
我相信这就是他正在寻找的:
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
SendKeys.Send("{ENTER}")
End Sub
As I understand it he wanted a button to press Enter for him, not that the button would be activated when pressing Enter.
据我了解,他想要一个按钮来为他按下 Enter,而不是按下 Enter 时会激活该按钮。

