读书人

关闭MDI 窗体时,其子窗体closing事件为

发布时间: 2012-04-25 19:32:32 作者: rapoo

关闭MDI 窗体时,其子窗体closing事件为 e.Cancel = true; 应该如何关闭MDI窗体?
希望我的描述比较清楚.

C# code
  SmartTimers smartTimers = new SmartTimers();  smartTimers.MdiParent = this;  smartTimers.Show();//SmartTimers窗口的 private void SmartTimers_FormClosing(object sender, FormClosingEventArgs e) {     e.Cancel = true;     this.WindowState = FormWindowState.Minimized; }


这样,比较痛苦的问题就来了,我想关闭MDI窗口,应该怎么关闭呢?
请各位有过这样问题的朋友帮个忙.

[解决办法]
设置一个静态公共变量,初始值为false
关闭子窗口时,判断该变量的状态,false为不关闭
要关闭MDI时,设置为true
C# code
  SmartTimers smartTimers = new SmartTimers();  smartTimers.MdiParent = this;  smartTimers.Show();//SmartTimers窗口的 private void SmartTimers_FormClosing(object sender, FormClosingEventArgs e) {     e.Cancel = Common.IsMDIExit;//Common.IsMDIExit为静态公共变量     this.WindowState = FormWindowState.Minimized; } 

读书人网 >asp.net

热点推荐