在C#中如何控制子窗体只在主窗体中显示一次:
有主要三步骤:
第一步,在要显示的子窗体中写如下代码:
pubulic static frmChild instance;
pubulic static frmChild Instance()
{
get {if(instance==null) {instance=new frmChild();}
return instance;
}
}
第二步,在主窗体中写如下代码:
frmChild frm=frmChild.Instance;
frm.Show();
frm.Activeate();
第三步,在frmChild.Designer中添加这样一句代码:
frmChild.instance=null;