Search code examples
c#.netwinformsformsmdiparent

Setting available region of MDI-Parent Form


I have an MDI-Parent form name frmMain where I load lots of child forms in.

frmMain has a Menu on the top which covers a space about say 1000*25. When child forms load, they can be born in any location of frmMain, and sometimes they go behind the menu.

Is there a way to make frmMain think the space under this menu should not be used (Something like form region)? Or I should explicitly tell the child forms to be located below height=25?

enter image description here

the blue portion is a menu and above it, the red portion is a panel.


Solution

  • I don't know if this is convenient for you, but you could add a Panel/FlowLayoutPanel to your Mdi window in the desired child forms space and add the forms to the panel like this :

    Form frm = New Form();
    frm.TopLevel = False;
    frm.Show();
    FlowLayoutPanel1.Controls.Add(frm);
    

    Set the FlowLayoutPanel.BackColor to Transparent so it looks like an mdi container.