两个窗体form1,form2.打开form1之后,点button1 关闭它 ,然后显示form2;我的代码是:
this.hide();
form2 f2=new form2();
f2.show();
//问题是this.hide();是把form1隐藏了,仍然驻留在内存中.
那么请问:怎样才能把form1彻底释放掉,再打开form2呢??
this.hide();
form2 f2=new form2();
f2.show();
//问题是this.hide();是把form1隐藏了,仍然驻留在内存中.
那么请问:怎样才能把form1彻底释放掉,再打开form2呢??
this.hide();
form2 f2=new form2();
f2.ShowDialog();
this.Close();
然后點擊BOOTON1的時候
先把變量改為TRUE
然后FROM1.CLOSE(); 就可以了主函數的為
Application.Run(new Form1());
if(HAHA=TRUE)
{ Application.Run(new Form2());}
button1_Click()
{
form2 frm2 = new form2();
frm2.show();
this.close();
}
推荐你用先前的思路,把窗体一hide掉
在窗体二的关闭事件里面加
Application.Exit();//结束应用程序
这样就可以把关联的窗体都干了.
button1_Click()
{
this.hide();
form2 frm2 = new form2();
frm2.show();
}
public static extern int SendMessage(int hWind,int msg,int wParam,int lparam)static IntPtr hand=IntPtr.Zero;定义完后,在方法里if(hand!=IntPtr.Zero)
SendMessage(hand.ToInt32(),0x00010,0,0)
hand=s.Handle;获取窗口的句柄,然后关闭前一个窗体
public Form2(Form1 f1)
{
f1.close();
}
button1_Click()
{
form2 frm2 = new form2(this);
frm2.show();
}
{
f1.close();
}
button1_Click()
{
form2 frm2 = new form2(this);
frm2.show();
}