实际上是窗口间通信的题目,在form1上翻开form2 ,form2 封闭时封闭form1
完成要领:
在子窗口form2中声明事宜:
public delegate void childclose(); public event childclose closefather; 然后在它的封闭事宜中触发本事宜: private void Form2_Closed(object sender, System.EventArgs e) { //用事宜去封闭主窗口 closefather(); }
在父窗口form1中(比方上岸窗口中):
然后弹出子form2窗体的处所如许写:
Form2 ff=new Form2(); ff.closefather+=new childclose(this.closethis); //closethis()是父窗体中的一个要领 ff.Show(); public void closethis() { this.Close(); }
以上就是c#完成封闭子窗口和封闭父窗口的案例的细致内容,更多请关注ki4网别的相干文章!