问题
I am working on a windows application form in visual studio 2012 where I am stuck in the UI design part. Actually, I am trying to open the child form in front of all the control objects (panel, table layout panel). This the parent form
When I open a child form all the objects of parent form go back
Here is the code inside my mdi parent form
frmControlAccount x;
private void controlToolStripMenuItem_Click(object sender, EventArgs e)
{
if (x == null || x.IsDisposed)//to avoid multiple opening of forms
{
x = new frmControlAccount();
x.MdiParent = this;
x.Show();
}
else
{
x.Focus();
x.BringToFront();
}
}
Since the form was not showing I tried this code too
private void MainPage_MdiChildActivate(object sender, EventArgs e)
{
if (ActiveMdiChild != null)
{
panel1.SendToBack();
picHomepage.SendToBack();
}
else
{
panel1.BringToFront();
picHomepage.BringToFront();
}
}
回答1:
You cannot put controls on the MDI Parent form, because this will make the client area of your MDI Parent smaller, and the MDI Child form will only be visible in the Client Area of the MDI Parent.
For example, put a Panel on your MDI Parent ( nothing else) and dock it left with a with of 200.
You will see that your MDI Child Forms will be visible, but you cannot move them over this panel.
That is how MDI Works.
If you want to show an image on the MDI Parent you can do it by painting it yourself in the paint event.
来源:https://stackoverflow.com/questions/44746664/bring-mdi-child-infront-of-mdi-parent-objects