3
votes

When a child form is opened it is hidden behind the title bar of MDI Parent Container.

enter image description here

The Child form's WindowState is set to Maximized. FormBorderStyle is set to None.

If I minimize the MDI parent and maximize it, then the child form comes in to front.

How to overcome this situation?

Edit:

I use the following code to open a child form.

    this.childForm= new ChildForm();
    this.childForm.MdiParent = this;
    this.WindowState = FormWindowState.Maximized;

    this.childForm.Dock = DockStyle.Fill;
    this.childForm.Show();
    this.childForm.BringToFront();
    this.childForm.Focus();
3

3 Answers

4
votes

Try the following code.

    Form1 newMDIChild = new Form1();
    newMDIChild.MdiParent = this;
    newMDIChild.Show();
    this.LayoutMdi(MdiLayout.Cascade);
    newMDIChild.Dock = DockStyle.Fill;
3
votes

The native Windows MDI implementation cannot deal with borderless MDI child windows. Unfortunately, Winforms forgets to enforce that restriction. You can move the WindowState assignment after the Show() call but that causes another problem.

Just don't make it borderless, the border isn't visible anyway.

0
votes
AboutBox1 ab = new AboutBox1();
ab.MdiParent = MDIForm.ActiveForm;
ab.TopMost = true;
ab.Show();