Bring mdi child infront of mdi parent objects

血红的双手。 提交于 2019-12-20 06:16:40

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!