private void toolStripButton1_Click(object sender, EventArgs e) { //利用MdiChildren遍历所有子窗体,并依次关闭 Form[] CFrmList = this.MdiChildren; foreach (Form CFrm in CFrmList) { CFrm.Close(); } }
private void toolStripButton1_Click(object sender, EventArgs e) { //利用MdiChildren遍历所有子窗体,并依次关闭 Form[] CFrmList = this.MdiChildren; //在这里我们定义了一个Form类型的数组CFrmList foreach (Form CFrm in CFrmList) { CFrm.Close(); } //此时窗体不太美观,我们对父窗体进行还原操作 this.label1.Visible = true; //还原父窗体上的标题文字; this.pictureBox1.Visible = true; //还原父窗体上的标题文字 this.label2.Visible = true; //还原父窗体上的版权文本 }