示例#1
0
 //關閉開啟的MDI子表單
 private void tsmClose_Click(object sender, EventArgs e)
 {
     foreach (Form MDIChild in this.MdiChildren)
     {
         MDIChild.Close();
     }
 }
示例#2
0
        //檔案功能表的「開新檔案」項目
        private void tsmNewFile_Click(object sender, EventArgs e)
        {
            MDIChild newChild = new MDIChild(); //建立子表單

            //將目前的表單指定為newChild的MDI父表單
            newChild.MdiParent = this;
            //記錄子表單的數量
            int count = this.MdiChildren.Length;

            //設定子表單的標題
            newChild.Text = $"我是子表單-{count.ToString()}";
            newChild.Show();    //顯示MDI子表單
        }