private void btnDashboard_Click(object sender, EventArgs e) { if (formDashboard == null) { formDashboard = new frmDashboard(); //Create form if not created //formDashboard.FormClosed += formDashboard_FormClosed; //Add eventhandler to cleanup after form closes } formDashboard.Show(this); //Show Form assigning this form as the forms owner Hide(); }
private void MasterForm_Load(object sender, EventArgs e) { connectDB.ConnectDatabase(); FormDashboard.MdiParent = this; FormDashboard.Dock = DockStyle.Fill; //Panel Show formsPanel.Controls.Clear(); FormDashboard.TopLevel = false; formsPanel.Controls.Add(FormDashboard); FormDashboard.Show(); }