Guest User

Guest User

  • Tech Writer
  • 529
  • 41k

How do I load a form on to a panel through a button inside another for

Oct 26 2021 6:49 PM
private void profile_Click(object sender, EventArgs e)
{
    openChildForm(new Form5());
}

private Form activeform = null;

private void openChildForm(Form childForm)
{
    if (activeform != null)
    {
        activeform.Close();
    }
    activeform = childForm;
    childForm.TopLevel = false;
    childForm.FormBorderStyle = FormBorderStyle.None;
    childForm.Dock = DockStyle.Fill;
    childFormPanel.Controls.Add(childForm);
    childFormPanel.Tag = childForm;
    childForm.BringToFront();
    childForm.Show();
}

 


Answers (2)