日期:2014-05-16  浏览次数:20914 次

C# 多个子窗体,关闭其中一个子窗体时其余子窗体也同时删除!!!
目前有5个窗体 Form1、Form2、Form3、Form4、Form5,其中Form1是主窗体,还有4个是子窗体。我想随便关闭一个子窗体后也连带把open状态的子窗体也一起关闭!
这个事件:Form3Closing(object sender, FormClosingEventArgs e)里面怎么写?其余类似,高手指点
------解决方案--------------------
foreach (var f in Application.OpenForms)
{
    if (f != this.Owner) // f is not the mainform
        f.Close();
}