Solved

Maximize Child Form inside MDI parent, VB.NET

Posted on 2010-08-25
5
9,153 Views
Last Modified: 2012-05-10
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!
0
Comment
Question by:slightlyoff
  • 3
5 Comments
 
LVL 17

Accepted Solution

by:
Zhaolai earned 500 total points
Comment Utility
Set your MDI child form's Dock property to Fill, like this,

        Form1.MdiParent = Me
        Form1.Dock = DockStyle.Fill
        Form1.Show()


0
 
LVL 85

Expert Comment

by:Mike Tomlinson
Comment Utility
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

0
 
LVL 85

Expert Comment

by:Mike Tomlinson
Comment Utility
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
0
 
LVL 1

Author Comment

by:slightlyoff
Comment Utility
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.
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
Comment Utility
No problem...good luck!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now