HI all,
I have this code in which the window property of making child window load at the center of mdiparent.
Form2 f = new Form2();
f.MdiParent = this;
//center screen is working.
//f.StartPosition = FormStartPosition.CenterScreen;
f.StartPosition = FormStartPosition.CenterParent;
but instead of making the child window pop at the center it loads at the left side. Can anyone help me on this. Please refer the screenshot below.
I have even tried doing the same in vb. Even there i get the same error. I think the property of FormStartPosition.CenterParent is dummy.
I experimented a bit with this, and first came to the same solution as Patrick. But I was bugged by the following statement in the documentation of the StartPosition
property:
You can also position the form to display in the center of the screen or in the center of its parent form for forms such as multiple-document interface (MDI) child forms.
So, I decided that there must be a way. And there is, though I don't find it all intuitive: set the StartPosition
to CenterScreen
(not CenterParent
):
MdiChildUI form = new MdiChildUI();
form.MdiParent = this;
form.StartPosition = FormStartPosition.CenterScreen;
form.Show();
Of course, you can also set it in the designer instead of in code.