I am using a MDI parent form that has a childs and they show up very well when they are called up by this parent and i use to intensiate child form as
ChildForm
write this code in a parent form....
childform obj = new childform( );
obj.MdiParent = this;
obj.StartPosition = FormStartPosition.CenterScreen;
obj.Show( );
To create a child from another child, just write it like this:
ChildForm sibling = new ChildForm();
sibling.MdiParent = this.MdiParent;
sibling.Show();
Or fire a custom event that the parent can respond to.
You should set the Parent to be the already existing mdiform, not create a new one.
If there isn't an instance of the mdiform already, you should not only create an instance of the form, but also show it.
var mdiForm = new MdiForm();
mdiForm.IsMdiContainer = true;
var childForm = new ChildForm();
childForm.MdiParent = mdiForm;
mdiForm.Show();
childForm.Show();
Also notice that I use mdiForm.IsMdiContainer
, AFAIK there is no IsMdiParent
property.
class MainClass
{
public string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
public void showWindow(Form openWin, Form closeWin, Form MDI)
{
closeWin.Close();
openWin.WindowState = FormWindowState.Minimized;
openWin.MdiParent = MDI;
openWin.Show();
}
}