假设要打开的窗口是Form41)在Form类中添加一个public static 变量.
public static Form4 f4 = null;2)打开Form4的代码这样写:
if (Form4.f4 == null)
{
Form4.f4 = new Form4();
Form4.f4.Show();
}
else
{
Form4.f4.Activate();
}
3)在Form4的Close中添加如下代码.
Form4.f4 = null;

解决方案 »

  1.   

    看我的:
      假设你的窗口是Form1类的实例
      设置一个全局变量,比如:public int count=0;
      每当打开一个窗口,相当于:
              方法1:     Form1 newForm1=new Form1();
                         newForm1.ShowDialog();
                         //此时你无须检测窗口是否打开,因为你不可能打开第二个窗口
              方法2:    if(count==0){
                                 Form1 newForm1=new Form1();
                                  count++;
                                 newForm1.Show();
                                   }
                        当然你必须在窗口的关闭事件中,加入:count=0;
      

  2.   

    同意snof(雪狼) ,使用静态变量.