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