C# Winform 按回车键查找下一个可设置焦点的组件

C# Code:
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;
}
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
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;
}
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
方式二:可特殊处理
C# Code:
Control current = this.GetNextControl(this.ActiveControl, true);
while (true)
{
if (current.CanFocus && current.CanSelect)
{
current.Focus();
break;
}
current = this.GetNextControl(current, true);
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
Control current = this.GetNextControl(this.ActiveControl, true);
while (true)
{
if (current.CanFocus && current.CanSelect)
{
current.Focus();
break;
}
current = this.GetNextControl(current, true);
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898

扫一扫加作者微信


版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网