MDI Maximized

I have MDI parent/child forms working. When I open the child form, I would like it to open maxmized and completely fill the parent form. I set the startup propertly to maiximized and while the form is in maximized state, it retains its design size and doesn't fill th parent. How can I fix this



Answer this question

MDI Maximized

  • Programm3r

    I can't reproduce this problem. Are you using VS2005


  • Davids Learning

    I'm getting the same results as Nobugs. It works for me.

    New windows project.

    Set Form1 as IsMdiContainer = true

    Resize Form1 in the IDE to make it twice as big.

    Add this code to Form1

    Public Class Form1

    Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated

    Form2.MdiParent = Me

    Form2.Show()

    End Sub

    End Class

    Then, Project, add Windows form (Form2). Then add this code to Form2.

    Public Class Form2

    Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    Me.WindowState = System.Windows.Forms.FormWindowState.Maximized

    End Sub

    End Class



  • BlackCatBone

    Roger, I am having the same problem. It's a datagridview on my MDI Child form that is staying at it's design time size, even though it's Dock property is set to Fill....

    Let me know if you get a solution to this!

    Cheers

    James



  • fields098

    Sorry, for anyone reading my post, I am coding in C#!

  • Aaron.W

    Again, this does the same thing as setting that property to maximized at design time. The buttons in the title bar of the child form are setup as if the form was maximized (ie the maximize button is showing the restore button) but it does not fill up the entire parent space. It is just the same size as it was at design time. If I restore or minimize it and then maximize it at run time with the title bar buttons, it then does maximize properly.

    So there must be a way to do this in the code before the form is shown.


  • Craig Schaepe

    hey,

    try the following code in the pleace where u initiate an mdi child

    Dim f as new form2()

    f.mdiParent = me

    f.windowstate = maximized

    f.show()

    hope this helps!



  • BCNO

    Dunno, sounds like a form event handler is messing this up. Start by commenting out any stuff in the Load, Shown and Resize events, if any. Or go the other way around with empty form code to start. Sorry for the crummy advice...


  • bikerchick

    Yep, making a call to

    this.WindowState = FormWindowState.Maximized;

    made all the difference. I should have tried that, but assumed that seeing as I had already set my forms WindowState to be Maximized at design-time, that it should have been........MAXIMIZED.

    Never mind, I guess it's just a quirk.

    Thanks..



  • CTheSoup

    Yes. Standard Edition 2005.

    Setting the Windowstate to minimized behaves the way you would expect. - Minimized inside the parent.

    The maximized setting forces the main parent menu bar to change to what it looks like when there is a maximized child (min/max/close buttons in the main menu bar). Hwever, the rest of the form except the title bar is painted in the parent container the size it was at design time. One cylce of minimize and then maximize using the runtime menu buttons makes it work properly.


  • MDI Maximized