选项卡式MDI应用程序 [英] Tabbed MDI Application

查看:79
本文介绍了选项卡式MDI应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个打开mdichild表单的mdi表单.当在mdiparent表单中打开mdichild时,如何查找放置在mdichild中的面板的确切位置?

I have a mdi form within which i am opening the mdichild forms.How to find the exact location of a panel placed inside the mdichild when it is opening inside the mdiparent form?

推荐答案

面板的位置相对于什么? Location属性将从其所在容器的左上角开始偏移,通常是托管该控件的窗体,即您的MdiChild窗体.

但是,您只需一点点数学就可以将该位置映射到MdiParent甚至屏幕内的位置.

回到基本问题...所有Mdi子窗体的引用都保存在MdiParent窗体的MdiChildren属性中,该属性返回一个Form对象数组.您只需要要查找的表单的索引.

或者,如果它确实是您真正需要的一种形式(如您现在要询问的那样),则可以在变量中保留对表单的引用,以便您可以随时访问它.

然后,只需查看要查找的面板的Forms Controls集合,然后查看其Location属性即可.
The location of the panel relative to what? The Location property is going to be an offset from the upper left corner of the container that it''s sitting in, usually the form that''s hosting the contorl, your MdiChild form.

But, you can map that location to the location inside the MdiParent or even the screen, with a little math.

Back to the base question... References to all Mdi Child forms are kept in the MdiParent forms MdiChildren property, which returns an Array of Form objects. You just need the index of the form you''re looking for.

Or, if it''s a form that you really need to get at, like you''re asking now, you can keep your own reference to the form in a variable so you have ready access to it.

Then, it''s just a matter of looking in that forms Controls collection for the Panel you''re looking for, then looking at it''s Location property.


首先,如果要创建选项卡式界面,则永远不要使用MDIChildFormMDIParent和其他MDI内容.您所谓的标签式MDI"根本不是MDI.

这很好.我建议:切勿使用MDI!但是选项卡式UI相当不错.
参见:
http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages [在WPF中使用MDI窗口的问题 [ ^ ],
提供错误的MDIContainer [ GUI外观-C#.Net [屏幕分辨率更改时,Zom Out发生故障 [ ^ ],
如何停靠按钮,以便它可以使用以下格式进行调整 [
First of all, if you''re creating tabbed interface, you should never use MDIChildForm, MDIParent and other MDI stuff. What you call "Tabbed MDI" is not MDI at all.

And this is good. I would advise: never use MDI! But Tabbed UI is quite good.
See:
http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages[^],
Question on using MDI windows in WPF[^],
MDIContainer giving error[^].

You never need to know exact location of this panel. The question is: location relative to what? You can translate all coordinates to scree coordinates. How to do it depends on what UI library you use: WPF, Forms or something else. You will easily find this conversion; for example, see System.Windows.Forms.Control.PointToScreen.

Always tag UI library when you ask a UI-related question!

You should always avoid using explicit coordinate of control. Instead, try to use Dock (or DockingPanel) with Padding and/or Margin.

Please see my direction for UI desing:
GUI Apperance - C#.Net[^],
Zom Out malfunctions when Screen resolution changes[^],
how to dock button so that it can adjust with the form[^] (code sample here).

—SA


这篇关于选项卡式MDI应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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