My child form opens up in a new window instead of opening within the MDI form when I use the below code:
Form1 f1 = new Form1();
f1.Dock = DockStyle.Fill;
f1.MdiParent = this.MdiParent;
this.WindowState = FormWindowState.Maximized;
f1.Show();
My child form opens up in a new window instead of opening within the MDI form when I use the below code:
Form1 f1 = new Form1();
f1.Dock = DockStyle.Fill;
f1.MdiParent = this.MdiParent;
this.WindowState = FormWindowState.Maximized;
f1.Show();
As @Keyur PATEL in comment suggested, you should set parent of "f1" form to the form object(not object MdiParent property) in which you want to inject "f1" form as MDI Child form ( not to the property of parent form, but to the object itself).
See more on Microsoft docs about MDI Apps.