private void companyToolStripMenuItem1_Click(object sender, EventArgs e) { Master.CompanyMasterForm cmpnymasterform = null; bool isFormOpen = IsAlreadyOpen(typeof(Master.CompanyMasterForm)); if (isFormOpen == false) { cmpnymasterform = new Master.CompanyMasterForm(); cmpnymasterform.StartPosition = FormStartPosition.CenterScreen; cmpnymasterform.MdiParent = this; cmpnymasterform.Show(); } } private bool IsAlreadyOpen(Type formType) { bool isOpen = false; foreach (Form f in Application.OpenForms) { if (f.GetType() == formType) { f.BringToFront(); f.WindowState = FormWindowState.Normal; isOpen = true; } } return isOpen; }
时间: 2024-10-17 15:53:22