4
votes

I am having this weird problem in Visual Basic (2013). I have a form in MDI container. Both of them, have property WindowState to Maximized. While executing, MDI container loads in maximized state (So far Ok!). But, when I open the child form, it Does NOT give the Actual Maximized state appearance (although Restore button on top right shows that it has loaded in maximized state, but it did not maximized).

I even tried with form1.WindowState = FormWindowState.Maximized both before and after form1.Show(), but no luck.

I have attached a screenshot too. Note the dead space of MDI container and Restore icon of child form (which means child form is in maximized state).

screenshot of VB problem

Few observations -

  1. When I restore and then again maximize it, it DOES maximize correctly.

  2. I also observed that this problem is occurs only for one time. I mean, if I have 2 forms both set to load in Maximized state. When I open the first form (no matter which), it loads like i showed in the screenshot, and after that when I open 2nd form, it loads in maximized state.

I could not figure out, what went wrong? How to correct this?

3
Show us code that duplicates the problem. Don't create MDI Child forms in the parent's constructor.LarsTech

3 Answers

7
votes

go to your form properties. Set windowsState = normal. then put this to code

    Dim frmC As New frmChild
    frmC.MdiParent = Me
    frmC.WindowState = FormWindowState.Maximized
    frmC.Show()
1
votes

I found that setting the MDI child form to maximized within the New routine of the class works always OK.

Public Sub New()
    ' This call is required by the designer.
    InitializeComponent()
    ' Add any initialization after the InitializeComponent() call.
    Me.WindowState = FormWindowState.Minimized
End Sub

OK, the last line may be one you may code under a condition...

0
votes

Check your icon. It must contain a 16x16 page. If the smallest is 32x32, the problem you illustrate will arise.