Correctly maximising MDI forms

I recently encountered an odd little quirk in visual .net.

When you create an instance of a form, as an MDI child, if you set the WindowState property to maximised, your form will not correctly span the whole window until you resize the parent.

After a bit of investigating on the internet, I came across many weird and wonderful suggestions,
things like setting the dock state of the form to ‘fill’, which works, right up until you want to un-maximise the form.

by far the easiest solution I have so far is as follows

dim frmMyFormInstance = New frmformTemplate()
With frmMyFormInstance
  .MdiParent = frmParent
  .Show()
 ' setting state in property of form results in incorrect display
  .WindowState = FormWindowState.Maximized
End With

That’s it, simple. Nothing fancy required like docking the form, or creating custom constructors that set properties before calling InitializeComponent(), just show the form, and then maximise it, not the other way about.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">