Member Avatar for Member #1042208

HI People, I have following situation.
I have an MDI form and a child form which opens upon selecting one of the menus.
When this chld form opens it opens with it's defalt size.

What I wish to do is open child forms maximized in parent when it(child) form is opened.

Thanks

Dani AI

Generated

Short answer: both of the replies already on this thread are valid, but the most reliable approach is to have the child form maximize itself at runtime rather than relying only on the designer. As pointed out you can set a child’s WindowState in the designer, and showed the usual pattern of creating an MDI child and assigning its MdiParent; for a robust runtime solution handle the child’s load/show timing so the maximize takes effect inside the MDI client area. (learn.microsoft.com)

A simple, reliable pattern is to put the maximize call in the child form’s Load event so it runs after the form is parented and initialized:

Private Sub ChildForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Me.WindowState = FormWindowState.Maximized
End Sub

That makes the child request maximized by the WinForms window manager and avoids timing/order issues. (learn.microsoft.com)

If you prefer to control this from the parent, set the child’s MdiParent and then apply WindowState after showing the child (ordering matters in some cases): show the form, then set its WindowState to Maximized. For dynamically reused forms be sure to reset any persisted WindowState before showing a reused instance. (stackoverflow.com)

Troubleshooting notes: confirm the parent’s IsMdiContainer is true, avoid docking an MDI child unless you intentionally want a single-document layout, and check that the child’s MaximumSize/MinimumSize or unusual FormBorderStyle aren’t preventing maximize. If a child has its own MenuStrip expect menu merging behavior when it becomes active. (learn.microsoft.com)

Recommended Answers

All 2 Replies

in the design tab of the child form set the WindowState property to Maximized

Hi,

If you set your form1 as a IsMdiContainer and form1 and form2 are set windowstate= Maximized then you can try this in the button event:

 Dim f As New Form2
        f.MdiParent = Me
        f.Show()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.