关闭子界面后关闭上一级界面

1.设置button的 DialogResult 属性

 

 2.上一级界面 获取值

 AdvanceOOCRules aoc = new AdvanceOOCRules();
            DialogResult dr = aoc.ShowDialog();
            if (dr == DialogResult.OK)// 子界面关闭后,会回调到这里
            {
                this.btnConfirm.PerformClick();      //调用按钮的点击方法      
            }
            else
                this.Close();

3.注意事件的调用 不要直接用方法,否则DialogResult    一直是false ,要用  this.btnConfirm.PerformClick(); 

 PerformClick :生成按钮的 System.Windows.Forms.Control.Click 事件。

posted @ 2022-10-12 16:08  乌柒柒  阅读(25)  评论(0编辑  收藏  举报