Solved

Maximize Child Form inside MDI parent, VB.NET

Posted on 2010-08-25
5
9,514 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

0
 
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!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to use odbc in vb to connect to ms sql 14 34
VB.Net How to Exit Sub - Exit Form??? 5 48
C# Single Form 8 27
Point to Current Row Ater Refresh Datagridview 3 20
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 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

19 Experts available now in Live!

Get 1:1 Help Now