什么是键盘输入按钮事件处理程序?

编程入门 行业动态 更新时间:2024-10-26 13:24:44
本文介绍了什么是键盘输入按钮事件处理程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在一个简单的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.

更多推荐

什么是键盘输入按钮事件处理程序?

本文发布于:2023-08-01 18:43:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1270739.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:按钮   键盘输入   事件   程序

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!