preSS Enter键移动到下一个控件 [英] Press Enter to move to next control
问题描述
我有在WinForm几个文本框。我想重点时回车键为pressed移动到下一个控制?每当一个文本框获得控制权,它也将选择文本,因此任何编辑将取代目前的之一。
I have a few TextBox on the WinForm. I would like the focus to move to the next control when Enter key is pressed? Whenever a textbox gains control, it will also select the text, so that any editing will replace the current one.
什么是做到这一点的最好方法是什么?
What is the best way to do this?
推荐答案
标签为输入:创建一个继承文本框的用户控件,重写键preSS
方法。如果用户presses输入,您可以调用 SendKeys.Send({TAB})
或 System.Windows.Forms.Control的。 SelectNextControl()
。注意:您可以使用达到相同的密钥preSS
事件。
Tab as Enter: create a user control which inherits textbox, override the KeyPress
method. If the user presses enter you can either call SendKeys.Send("{TAB}")
or System.Windows.Forms.Control.SelectNextControl()
. Note you can achieve the same using the KeyPress
event.
焦点全文:再次通过覆盖或事件,目标在的GotFocus
事件,然后调用 TextBox.Select
方法。
Focus Entire text: Again, via override or events, target the GotFocus
event and then call TextBox.Select
method.
这篇关于preSS Enter键移动到下一个控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!