Solved

Maximize Child Form inside MDI parent, VB.NET

Posted on 2010-08-25
5
9,845 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
ID: 33523584
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
ID: 33523929
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

1
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 33525054
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
ID: 33525160
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
ID: 33525247
No problem...good luck!
1

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 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