什么是键盘输入按钮事件处理程序? [英] What is Keyboard Enter Button event handler?

查看:83
本文介绍了什么是键盘输入按钮事件处理程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个简单的Windows窗体应用程序中,有3个文本框和1个按钮.

说程序的用户可能想用这种形式输入很多数据.
每次他/她填充文本框并用鼠标按Enter键或在填充最后一个文本框后,他/她按键盘上的TAB键并按Enter键比使用鼠标更快.
但是它仍然很慢.

当用户填充第三个文本框并按Enter键然后程序保存数据时,是否会运行事件处理程序?


示例:与google搜索引擎一样,您可以在thex框中输入词组并按Enter键,然后搜索就会开始.

我希望这使我的表单对用户最友好.
我无法识别事件处理程序.

请帮助

In a simple windows form application there is 3 textbox and 1 button.

Say a user of program may want to enter a lot of data with this form.
Every time he/she fills the textboxes and press enter button by mouse or after filling last textbox he/she pushes the TAB key in keyboard and pushes the Enter key which is faster than using mouse.
But it is still slow.

Is there an event hander which runs when user fill the 3rd textbox push Enter Key then program save data?


Example: Like google search engine, you enter your phrase in thex box and pushing the Enter key, then searching will be started.

I want this for making my form most user friendly.
I can''t recognize the event handler.

Please help

推荐答案

使用3 rd 文本框的Keypress事件.在该事件处理程序内,您所需要做的就是检查用户是否按了enter键,然后调用了保存数据,清除表格并跳回到第一个输入字段的例程.

祝您编程愉快!
Use the Keypress event of the 3rd TextBox. Inside that event handler all you have to do is to check if the user pressed the enter button and then call the routine that saves the data, clears the form and jumps back to the first input field.

Happy coding!


您是否尝试过捕获第3个文本框的KeyUp事件?事件处理程序包含有关已按下键的信息!

Have your tried catching the 3rd textbox''s KeyUp event? The event handler contains information about the key that was pressed!

if (e.KeyCode == KeyCodes.Enter)
{
  // Do stuff!
}



玩得开心!

Eduard



Have fun!

Eduard


将表单的AcceptButton属性设置为您的按钮名称.
Set the AcceptButton property of form as your button name.


这篇关于什么是键盘输入按钮事件处理程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆