3
votes

I have a MDI Parent form which contains a panel. The panel includes charts and a some other user information's. When I open a form from menu, the newly opened form is shown under the MDI parent panel. How can I show the child form above of all MDI Parent control's. I'm using the below code for opening the form.

SalesInvoice sale = new SalesInvoice();
sale.MdiParent = this;
sale.Show();

enter image description here

2
You're adding that Panel to the MdiParent Form, while the child Forms are added to the MdiClient container. Your Panel will always be on top of other Controls. You could use a borderless, docked child Form instead. Or come up with another type of layout completely.Jimi
You need to DOCK that Panel. Once docked, the MDI Child forms will properly take up any remaining space.Idle_Mind
@Idle_Mind If you dock the Panel inside the MdiParent (of course you cannot dock it inside the MdiClient), you also need to SendToBack() the MenuStrip, ToolStrip(s) and StatusStrip, otherwise the Panel will overlap them. The mdi child Forms will go under the Panel anyway (since those are still in a lower hierarchy).Jimi
It is the difference between using Show() and ShowDialog(). The ShowDialog() os blocking and waits for the child form to close before returning to parent. Show will keep child open and return to parent (provided you do not close the child on exit).jdweng

2 Answers

0
votes

First, in your child form properties, in FormBorderStyle property, choose (None).

Second, replace your code to show your child form to this:

Sale.StartPosition = FormStartPosition.Manual
Sale.Left = 200
Sale.Top = 115
Sale.MdiParent = Me
Sale.Show()

you could change (200) and (115) to your desired directions.

0
votes

You can make the form maximize when you show the form.

Please refer to the following code.

private void button1_Click(object sender, EventArgs e)
        {
            SalesInvoice sale = new SalesInvoice();
            sale.MdiParent = this;
            sale.Show();
            sale.WindowState = FormWindowState.Maximized;
        }