0
votes

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
Why are you making this more complicated than it has to be? Use two separate forms and drop the “MDI” idea. Using an “MDI” approach appears unnecessary and only complicates what you are trying to achieve.JohnG

1 Answers

0
votes

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.