如何集中控制KeyPress事件 [英] How to focus control for KeyPress event
本文介绍了如何集中控制KeyPress事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发计算器程序。如何将TextBox重点放在KeyPress事件上。所以它准备好从键盘输入。我的程序需要点击该文本框然后从键盘输入。
我希望文本框能够自动聚焦在按键事件上。不需要在该文本框上手动单击以便我从键盘输入。
这是Windows窗体应用程序。
textbox1.focus();
无效。
解决方案
< blockquote>如果它是一个Web应用程序你的文本框id点焦点在jquerry。
请提及使用你的工作。
首先查看TabOrder您的表格:
https:// msdn。 microsoft.com/en-us/library/aa984423(v=vs.71).aspx [ ^ ]
或
http://webcheatsheet.com/HTML/controll_tab_order。 php [ ^ ]
当表单/页面加载时,最低的Tab键顺序控件获得焦点。
如果你需要设置一个特定的控件以编程方式获得焦点,那么你可以做适用于Winforms的焦点方法 [ ^ ]
尝试...
TextBox1。选择
I am developing calculator program.How can I focus TextBox for KeyPress event.So That It will ready to take input from keyboard.My program need to click on that textbox then its take input from keyboard.
I want textbox to get focused automatically on keypress event.No need to click manually on that textbox so that i will take input from keyboard.
This is windows form application.
textbox1.focus();
didnt work.
解决方案
if it is an Web Application Your text box id dot focus in jquerry.
Kindly Mention using Which your working .
Start by looking at the TabOrder for your form:
https://msdn.microsoft.com/en-us/library/aa984423(v=vs.71).aspx[^]
Or
http://webcheatsheet.com/HTML/controll_tab_order.php[^]
The lowest tab order control gets the focus when the form / page loads.
If you need to set a specific control to get the focus programmatically, then you can do it for Winforms with the Focus method[^]
Try ...
TextBox1.Select
这篇关于如何集中控制KeyPress事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文