当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - MDIchild form goes behind the panel

问题描述:

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

网友答案:

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.

网友答案:

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....

网友答案:

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.

网友答案:

I just added the BringToFront method after the Show method.

works fine for me.

分享给朋友:
您可能感兴趣的文章:
随机阅读: