日期:2014-05-18 浏览次数:21002 次
public class SelectForm : System.Windows.Forms.Form { private static SelectForm SelFormInstance; public static void SelectForm GetInstance() { if(SelFormInstance == null) { SelFormInstance = new SelectForm (); } return SelFormInstance ; } // 点确定时,窗口被CLOSE了。 public void btnOK_Click(object sender, EventArgs e) { this.close(); } }
public class SelectForm : System.Windows.Forms.Form { private static SelectForm SelFormInstance; public static void SelectForm GetInstance() { if(SelFormInstance == null) { SelFormInstance = new SelectForm (); SelFormInstance.Close += onclose; } return SelFormInstance ; } static void onclose(object sender, EventArgs e) { SelFormInstance = null; } // 点确定时,窗口被CLOSE了。 public void btnOK_Click(object sender, EventArgs e) { this.close(); } }
------解决方案--------------------
this.Dispose();
------解决方案--------------------
Main方法执行完了肯定就释放了.
你所谓的"存在",A窗体CLSOE后B窗体还可以访问么?
你自己试试在A窗体添加一个静态全局变量,看可不可以访问咯.
结论是---静态是首次调用后,便永远存在了(if ...Main.Run ...).