首页 > 代码库 > 限制窗口重复开启

限制窗口重复开启

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;}

限制窗口重复开启