c#.net 中Form childForm in MdiChildren这几句什么意思?

来源:百度知道 编辑:UC知道 时间:2024/06/01 11:43:26
private void 重新登录ToolStripMenuItem_Click(object sender, EventArgs e)
{
foreach (Form childForm in MdiChildren)
{
childForm.Close();
}
loginForm for1 = new loginForm();//实例化登录窗口
for1.Show();//显示登录窗口
System.IO.FileStream fs = new System.IO.FileStream("chimes.wav", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
System.Media.SoundPlayer sp = new System.Media.SoundPlayer(fs);
sp.Play();
this.Hide();//隐藏主窗体
}
在上面那段程序中,以下的代码是 什么意思,我是菜鸟,请高手详细解说下,谢谢!
foreach (Form childForm in MdiChildren)
{
childForm.Close();
}

MDI是多文档界面,MdiChildren是多文档界面的子窗体
这句意义就是关闭所有多文档的子窗体

循环查找,如果Form的类型是MdiChildren(MDI的子窗体),那么就关闭

关掉所有Mdi窗口

意思就是关掉所以的在父容器里面的子窗体。