Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximized state of child form Not working correctly when used in MDI container (Visual Basic 2013)

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?

like image 988
Dr. Atul Tiwari Avatar asked Feb 12 '23 12:02

Dr. Atul Tiwari


2 Answers

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()
like image 171
yul Avatar answered May 10 '23 18:05

yul


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...

like image 35
MBAH Avatar answered May 10 '23 17:05

MBAH