c# 怎么样做到按回车键自动跳到下一个控件
展开全部
先设置这些控件的Tab顺序,然后在窗体的后台代码中添加如下函数就可以了:
protected override bool ProcessDialogKey(Keys keyData){if (keyData == Keys.Enter) // 按下的是回车键{foreach (Control c in this.Controls){if (c is System.Windows.Forms.TextBox) // 当前控件是文本框控件{keyData = Keys.Tab;}}keyData = Keys.Tab;}return base.ProcessDialogKey(keyData);}
protected override bool ProcessDialogKey(Keys keyData){if (keyData == Keys.Enter) // 按下的是回车键{foreach (Control c in this.Controls){if (c is System.Windows.Forms.TextBox) // 当前控件是文本框控件{keyData = Keys.Tab;}}keyData = Keys.Tab;}return base.ProcessDialogKey(keyData);}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询