private void CloseForm() { if (m_QueryCompanyForm != null) { m_QueryCompanyForm.Close(); m_QueryCompanyForm = null; } if (m_QueryEmployeeForm != null) { m_QueryEmployeeForm.Close(); m_QueryEmployeeForm = null; } if (m_AddCompanyForm != null) { m_AddCompanyForm.Close(); m_AddCompanyForm = null; } if (m_AddEmployeeForm != null) { m_AddEmployeeForm.Close(); m_AddEmployeeForm = null; } if (m_AddCompanyListForm != null) { m_AddCompanyListForm.Close(); m_AddCompanyListForm = null; } }
private void btnAddCompany_Click(object sender, EventArgs e) { CloseForm(); this.IsMdiContainer = true; m_AddCompanyForm = new AddCompanyForm(); //实例化子窗体 m_AddCompanyForm.MdiParent = this; //设置窗体的父子关系 m_AddCompanyForm.Parent = plContainer; //设置子窗体的容器为父窗体中的Panel m_AddCompanyForm.Dock = DockStyle.Fill; m_AddCompanyForm.Show(); //显示子窗体,此句很重要,否则子窗体不会显示 }