private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
if (this.ActiveControl != null)
{
bool b = this.SelectNextControl(this.ActiveControl, true, true, true, false);
}
}
}
MSDN:
Control.SelectNextControl 方法:激活下一个控件。
public bool SelectNextControl( Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap )
参数
- ctl
- 类型:System.Windows.Forms.Control
Control。
- forward
- 类型:System.Boolean
false 则在 Tab 键顺序中后移。
- tabStopOnly
- 类型:System.Boolean
false 表示不忽略。
- nested
- 类型:System.Boolean
false 表示不包括。
- wrap
- 类型:System.Boolean
false 表示不继续搜索。
SelectNextControl 方法将激活 Tab 键顺序中的下一个控件。
从该列表中的控件派生的控件也是不可选择的。
-
LinkLabel(当控件中没有链接时)
ContainerControl.ActiveControl 属性设置为当前窗体等方式更改焦点时,焦点事件按以下顺序发生:
Validated 事件。