HOW TO: Make a MDI child window start up in center of parent window

When creating a new instance of a MDI child form, the form will load in cascading order in relation to the open forms by default. Most of the time this is acceptable, but if you run into a situation where you want to load it in the center of the parent you may run into a bit of trouble.The default property for showing a form in the center of a parent looks like this:


MdiChildUI form = new MdiChildUI();
form.MdiParent = this;
form.StartPosition = FormStartPosition.CenterParent;


Dim form As New MdiChildUI
form.MdiParent = Me
form.StartPosition = FormStartPosition.CenterParent

To make the window show by default in the center of a MDI parent, you must set the StartPosition to be CenterScreen as opposed to CenterParent. In a MDI environment, child forms consider the parent MDI window to be their screen.


form.StartPosition = FormStartPosition.CenterScreen;


form.StartPosition = FormStartPosition.CenterScreen

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=""> <s> <strike> <strong>