2
Answers

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

Guest User

Guest User

3y
510
1
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)