c# 判断窗体已打开则显示为焦点
MDI编程模式
private void menuItem3_Click(object sender, System.EventArgs e) //菜单的CLICK事件.
{
FrmClass MyClass = null; //生成自己的表单
foreach( Form ftemp in this.MdiChildren) //查找当前父表单所有子表单
{
if(ftemp is FrmClass)
{
MyClass = (FrmClass)ftemp;
break;
}
}
if(MyClass==null || MyClass.IsDisposed)
{
MyClass = new FrmClass();
MyClass.MdiParent = this;
}
MyClass.Show();
MyClass.Activate();
}
普通显示模式:
private void lblCopyRight_Click(object sender, EventArgs e)
{
Form2 frm = null;
foreach (Form frmt in Application.OpenForms)
{
if (frmt is Form2)
{
frm = (Form2)frmt;
break;
}
}
if (frm == null)
(new Form2()).Show();
else
{
frm.Show();
frm.Activate();
}
}
注:该文是摘自
http://www.cnblogs.com/vic_lu/archive/2011/05/20/2052016.html
c# 判断窗体已打开则显示为焦点
最新推荐文章于 2022-07-28 19:04:55 发布