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 btnAddEmployee_Click(object sender, EventArgs e) { CloseForm(); this.IsMdiContainer = true; m_AddEmployeeForm = new AddEmployeeForm(); //实例化子窗体 m_AddEmployeeForm.MdiParent = this; //设置窗体的父子关系 m_AddEmployeeForm.Parent = plContainer; //设置子窗体的容器为父窗体中的Panel m_AddEmployeeForm.Dock = DockStyle.Fill; m_AddEmployeeForm.Show(); //显示子窗体,此句很重要,否则子窗体不会显示 }