关闭窗体
我有两个窗体Form1和Form2,通过第一个窗体上的Button1打开Form2,再通过第二个窗体上的Button1关闭第一个窗体Form1请问代码该怎样 写,等着急用!!!!!!!!!!!!!
public partial class Form1 : Form { public Form1() { InitializeComponent(); } public delegate void CloseForm1(); private void button1_Click(object sender, EventArgs e) { Form2 f2 = new Form2(); f2.event1 += new CloseForm1(CloseForm); f2.Show(); } private void CloseForm() { this.Close(); } }
public partial class Form2 : Form { public Form2() { InitializeComponent(); } public event Form1.CloseForm1 event1; private void button1_Click(object sender, EventArgs e) { event1(); } }