3

I have a panel in a MDI form and there are some controls in the panel. When I open MDIChild forms, the forms go behind the panel. I tried forms.BringtoFront() and panel.SendtoBack().But nothing works. Then I set setchildIndex of panel to 0,didn't work too.

Is there any way to keep the panel always behind all the forms ?

Thanks

AlaaL
  • 333
  • 9
  • 28
  • 1
    Why would you have a panel in an MDI container? You are meant to put MDI children in the MDI container. – David Heffernan Mar 13 '11 at 19:49
  • Yes i know, but i want the mdi parent to be like a desktop or main page for my application and also the user can open another mdi children from main menu – AlaaL Mar 13 '11 at 20:16
  • And i want to say it's not just panel, if you put any control on the mdi parent it is stay on the top of other forms. – AlaaL Mar 13 '11 at 20:17

5 Answers5

2

Create a new empty form and then set following property of this form in the Form_load event

private void bg_Load(object sender, EventArgs e)
{
    this.ControlBox = false;
    this.FormBorderStyle = FormBorderStyle.None;
    this.WindowState = FormWindowState.Maximized;
}

then after, write the following code in the MDI form load event

private void Main_Load(object sender, EventArgs e)
{
    bg bg = new bg(); // create object of empty form my empty form name is "bg"
    bg.MdiParent = this;
    bg.Show();
}

whatever you want in the background, add into empty form....

Robert Longson
  • 118,664
  • 26
  • 252
  • 242
Vishal Thoriya
  • 283
  • 5
  • 19
2

The problem is that the container for the the MDI children is a sibling of the panel. The panel is either on top of that container or behind it.

You want the panel to be in the same container as the MDI children, but I don't believe that to be possible. The MDI container holds MDI children and nothing else.

In short, I don't think MDI is going to give you what you need.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
0

Place a flowlayout container add the child to it and it will be on the top of other panel

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
MANOJ AP
  • 1
  • 1
0

Could you put the panel into an MDI child window and fix its position and size within the MDI parent? Then just make it so that only one type of MDI child window that contains your panel can be opened at a time within your MDI parent.

Frank Rundatz
  • 156
  • 1
  • 4
0

I just added the BringToFront method after the Show method.

works fine for me.

Venkatesh
  • 11
  • 2