日期:2014-05-19  浏览次数:20758 次

c#.net 中如何在一个窗体中关闭另一个窗体?
c#.net   中如何在一个窗体中关闭另一个窗体?

------解决方案--------------------
把另外一个窗体作为成员变量,form1.Close();
------解决方案--------------------
我想在子窗体关闭的时候,同时关闭new子窗体的父窗体,怎么办呢?
------解决方案--------------------
是,整个程序关闭么?
------解决方案--------------------
声明一个父窗体的变量,用变量.Dispose();
还可以使用 Application.Exit();

------解决方案--------------------
Application.Exit();

------解决方案--------------------
Application.Exit();
------解决方案--------------------
可以使用事件触发,但是耦合性强了

------解决方案--------------------
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Form2 f2;
private void button4_Click(object sender, EventArgs e)
{
if (f2 == null)
{
f2 = new Form2();
f2.Show();
}

}

private void button3_Click(object sender, EventArgs e)
{
if (f2 != null)
{
f2.Close();
f2 = null;
}
}
}