当前位置:编程学习 > C#/ASP.NET >>

关于c#窗口弹出问题

在form1按钮中的代码:  Form2 fm2 = Form2.CreateInstance();
                    if (fm2 !=null)
                  { 
                    fm.Show(); 
                   }
在form2中的代码:   namespace Bastekball
                      {
                  public partial class Form1 : Form
                      {
                      private static bool instanceFlag = false;
                      public static Form1 CreateInstance()
                     {
                      return instanceFlag ? null : new Form1();
                      }
用这样的方法可以完成form2只弹出一次,但是当关闭form2后,再次点击form1中的按钮,form2就再也弹不出来了,求大神帮忙修改一下,实现关闭form2后,点击按钮还可以再次弹出 
          
c# --------------------编程问答-------------------- 帮你移到c#版块了 --------------------编程问答-------------------- private static Form1 instance = null;
                      public static Form1 CreateInstance()
                     {
                      if(instance==null  || instance.Disposed()  ) instance = new Form1();
return instance ;
                      }

  
*****************************************************************************
http://feiyun0112.cnblogs.com/ --------------------编程问答--------------------   return instanceFlag ? null : new Form1();
改成楼上的
  if(instance==null  || instance.Disposed()  ) instance = new Form1();
return instance ;
就可以了 --------------------编程问答-------------------- http://www.cnblogs.com/whz881027/articles/2103274.html
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,