private void frmLogin_KeyPress(object sender, KeyPressEventArgs e)
{
//按回车键查找下一个可设置焦点的组件。
if (e.KeyChar == (Char)Keys.Enter)
{
this.SelectNextControl(this.ActiveControl, true, true, true, true);
e.Handled = true;
}
}
第二种方法:可特殊控制
Control current = this.GetNextControl(this.ActiveControl, true);
while (true)
{
if (current.CanFocus && current.CanSelect)
{
current.Focus();
break;
}
current = this.GetNextControl(current, true);
}