assume you are talkinga bout Winform, see27.13 How can I make the focus move to the next control when the user presses the Enter key in a TextBox?
http://www.syncfusion.com/FAQ/WinForms/FAQ_c94c.asp
protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
{
if(msg.WParam.ToInt32() == (int) Keys.Enter)
{
SendKeys.Send("{Tab}");
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
http://www.syncfusion.com/FAQ/WinForms/FAQ_c94c.asp
protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
{
if(msg.WParam.ToInt32() == (int) Keys.Enter)
{
SendKeys.Send("{Tab}");
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
设置窗口上控件的TabIndex
在窗口的KeyDown事件编码:
if (e.KeyCode == System.Windows.Forms.Keys.Enter){
System.Windows.Forms.SendKeys.Send("{TAB}");
}
SendKeys.Send("{TAB}");
}