窗体的关闭问题
假如现在打开了两个form ,form1和form2form1有一button,点击
先关闭form2,然后关闭form1,为什么就关不了呢?
代码如下:
form2 f2=new form2();
f2.Close();
this.Close();
不会吧,我这里可以啊!
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
private void Form1_Load(object sender, EventArgs e)
{
Form2 form2 = new Form2();
form2.Show();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 form2 = new Form2();
form2.Close();
this.Close();
}