try { bool isOpen = false; foreach (Form frm in this.ParentForm.MdiChildren) { //if (this.ActiveMdiChild == frm)//如果窗口為當前活動的子窗口才處理 if (frm.Name == "frmQAReport") { isOpen = true; ShareForm mf = frm as ShareForm; mf.RefreshQAReport(); frm.Activate(); } } if (isOpen == false) { Form ofrmQAReport = new frmQAReport(); ofrmQAReport.MdiParent = this.ParentForm; ofrmQAReport.WindowState = FormWindowState.Maximized; ofrmQAReport.Show(); ofrmQAReport.Activate(); } } catch (Exception Err) { MessageBox.Show(Err.Message); }