其实是窗口间通讯的问题


实现方法:

在子窗口中声明事件:

    public event childclose closefather;

    然后在它的关闭事件中触发本事件:

     private void Form1_Closed(object sender, System.EventArgs e)
     {
       //用事件去关闭主窗口
        closefather();
      }



在父窗口中(登陆窗口中):


    在窗口类之前,在共同的命名空间之后声明代理:

     public delegate void childclose();
   
   然后弹出子窗体的地方这样写:

   Form1 ff=new Form1();
    ff.closefather+=new childclose(this.closethis); //closethis()是父窗体中的一个方法
    ff.Show();

   定义方法:

     public void closethis()
    {
     this.Close();
     }

完!

相关文章:

  • 2021-12-10
  • 2021-12-04
  • 2021-12-15
  • 2021-12-23
  • 2021-12-23
  • 2021-11-19
  • 2021-12-29
  • 2021-12-23
猜你喜欢
  • 2021-09-14
  • 2021-12-23
  • 2021-12-23
  • 2021-12-19
  • 2021-08-27
  • 2021-12-20
  • 2021-12-05
  • 2021-12-26
相关资源
相似解决方案