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; }
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)