Search code examples
c#winformspanelparent-childmdiparent

MDI Parent Child Form location problems


I know using the follwing two methods for showing a form in another form

method1

public Form1()
{
    InitializeComponent();

    Form2 embeddedForm = new Form2();
    embeddedForm.TopLevel = false;
    Controls.Add(embeddedForm);
    embeddedForm.Show();
}

method 2

Form1 fChild = new Form1();
fChild.MdiParent = this;
fChild.Show();

i need to learn how to display this child form in a panel of the parent form

or if somebody can tell me how to set the x,y coordinates of the child form


Solution

  • You can change the parent of the form at any time, e.g.:

    fChild.TopLevel = false;
    fChild.Parent = fParent.panel1;