如何使mdichild负荷的MdiParent窗口的中心 [英] How to make mdichild load at the center of mdiparent window

查看:190
本文介绍了如何使mdichild负荷的MdiParent窗口的中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我有这样的代码,其中在的MdiParent的市中心,使子窗口负荷的窗口属性。

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.

我甚至试图做同样的在vb。即使在那里我得到了同样的错误。我认为FormStartPosition.CenterParent的属性是假人。

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.

推荐答案

我尝试了一下这个问题,并首先来到了相同的溶液帕特里克。但我在的<$ C的文档$ C>中StartPosition 属性:

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:

您也可以放置在窗体到
显示在屏幕或
在为
形式,比如多文档
接口(MDI)子窗体的父窗体的中心的中心。

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.

所以,我决定必须有一种方式。还有就是,尽管我不觉得这一切直观:设置中StartPosition 中心屏幕 CenterParent ):

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.

这篇关于如何使mdichild负荷的MdiParent窗口的中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆