Link to home
Start Free TrialLog in
Avatar of slightlyoff
slightlyoff

asked on

Maximize Child Form inside MDI parent, VB.NET

How do I maximize the child form so it fills the MDI Parent?
My MDI parent fills the entire monitor, but the child only fills a portion of the MDI Parent.  Since I dont' always know what resolution someone will be viewing at, I can't really hard code this.

Any ideas?

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Zhaolai
Zhaolai
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mike Tomlinson
Set the WINDOWSTATE of the MdiChild to Maximized and it will fill the entire MdiParent...
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim f2 As New Form2
        f2.MdiParent = Me
        f2.WindowState = FormWindowState.Maximized
        f2.Show()
    End Sub

End Class

Open in new window

Just FYI, the two answers above produce different results...the "correct" one depends on your app I suppose.  =)

Dock.Fill doesn't merge with the MdiParent or update the main Form caption while WindowState.Maximized does:
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim f2 As New Form2
        f2.mdiparent = Me
        f2.Dock = DockStyle.Fill
        f2.Show()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim f2 As New Form2
        f2.MdiParent = Me
        f2.WindowState = FormWindowState.Maximized
        f2.Show()
    End Sub

End Class

Open in new window

MdiChildDockFilled.jpg
MdiChildWindowstateMaximized.jpg
Avatar of slightlyoff
slightlyoff

ASKER

I appreciate the insight.  I saw that it worked and awarded the points (i didn't get a chance to test your solution) - but I can see where your answer is correct as well.

thank you for going the extra mile to explain the difference!  It's helpful for a newb like me.
No problem...good luck!