如何在不单击的情况下触发表单上的默认按钮(winforms)? [英] How can I trigger the default button on a form without clicking it (winforms)?
问题描述
我有两个文本框.一个用于登录ID,另一个用于密码.并且有一个按钮(提交).我需要一个采用登录 ID 和密码值的事件.即,无需单击鼠标,我需要调用此事件(只需按键盘上的输入"即可).谁能帮帮我!
提前谢谢.斯里尼
Simon P Stevens 给了你最充分的答案.
我只想补充一点,您还可以设置表单的取消按钮,当您按下转义 ESC 键时,将在该按钮上触发点击事件.>
快速总结
回车 --> 接受按钮
Esc --> 取消按钮
I have two text boxes. one for login id and another is for password. and there is one button (submit). I need an event that takes the values of login id and password. I.e, without clicking the mouse I need to invoke this event(just by hitting 'enter' on keyboard). can anybody help me!
thanx in advance. srini.
Simon P Stevens gave you the most adequate answer.
I would just add that you also have the possibility to set a form's CancelButton on which a click event would be triggered when you press the escape ESC key.
Quick summary
Enter --> AcceptButton
Esc --> CancelButton
这篇关于如何在不单击的情况下触发表单上的默认按钮(winforms)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!