// 遍历并关闭所有子窗口
FormCollection childCollection = Application.OpenForms;
for (int i = childCollection.Count; i-- > 0;)
{
if (childCollection[i].Name != “父窗口标题”) childCollection[i].Close();
}
// 或者也可以这样写:
FormCollection childCollection = Application.OpenForms;
for (int i = childCollection.Count; i-- > 0;)
{
if (childCollection[i].Name != this.Title) childCollection[i].Close();
}
11-05
928
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)