如何在父窗口,C#Windows应用程序中打开子窗口 [英] How to open Child window in parent window,C# windows Application

查看:287
本文介绍了如何在父窗口,C#Windows应用程序中打开子窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在父窗口,C#Windows应用程序中打开子窗口?

How to open Child window in parent window,C# windows Application?

推荐答案

chk from codeproject此链接

使用C#(演练)创建MDI应用程序 [
chk this link from codeproject

Creating MDI application using C# (Walkthrough)[^]


你好朋友,

设置您的表单属性ISMDIContainer = true
Hi friend,

Set ur Form property ISMDIContainer=true


表单之间没有功能父子关系.

我的意思是,Form仍然具有父级的属性 System.Windows.Forms.Control.ParentSystem.Window.Forms.Control.Controls,但是如果您尝试使一种形式成为另一种形式的子代,则这些属性将失效.将引发异常.

有一种解决方法,但我建议不要使用它.您可以将Form.TopLevel属性分配为false,然后可以将这种形式作为其他形式的子项插入.看起来很难看.如果子窗体具有非客户区,则父窗体将与所有非客户区一起进入父窗体.

Windows并非真正设计为使用此类病理性事物.这将违反大多数基本设计原则.同样,这是永远不需要的.对于Form的子级,可以使用其他容器控件,例如PanelTabControl等.

请查看我过去关于该主题的答案:
父级子窗体关系 [ ^ ].

另请参见:

http://msdn.microsoft.com/en-us/library/system. windows.forms.form.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system. windows.forms.control.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system. windows.forms.panel.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system. windows.forms.tabcontrol.aspx [ ^ ].

我没有提到非常不同的关系:MDI父级和MDI子级之间.这是完全不同的故事,但是我不建议使用MDI.即使Microsoft也不建议这样做.您不必折磨头,也不必用这种丑陋的风格吓users用户.

请参阅:

http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages [如何在WPF中创建MDI父窗口? [ ^ ],
在WPF中使用MDI窗口的问题 [ ^ ],
MDIContainer提供错误 [如何最大程度地设置子表单,最小化最后一个子表单 [ ^ ].

上面引用了我过去的一些答案,我将解释您可以做什么.
There is no functional child-parent relationship between forms.

I mean, Form still have child-parent properties System.Windows.Forms.Control.Parent and System.Window.Forms.Control.Controls but these properties are made defunct if you try to make one form a child of another form. An exception will be thrown.

There is a work-around, but I would advise not to use it. You can assign Form.TopLevel property to false, and then such form could be inserted as a child of another form. It will look ugly. If the child form has non-client area, the parent form will go inside the parent form with all the non-client area.

Windows is not really designed to use such pathological things. This would violate most basic design principles. Also, this is never needed. For a children of the Form you can use other container controls like Panel, TabControl and the like.

Please see my past answer on this topic: Parent Child Form Relationship[^].

See also:

http://msdn.microsoft.com/en-us/library/system.windows.forms.form.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.panel.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol.aspx[^].

I did not mention a very different relationship: between MDI parent and MDI children. This is totally different story, but I don''t recommend using MDI. It is highly discouraged even by Microsoft. You don''t need to torture your head and scare off you users with this ugly style.

Please see:

http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages[^],
How to Create MDI Parent Window in WPF?[^],
Question on using MDI windows in WPF[^],
MDIContainer giving error[^],
How to set child forms maximized, last childform minimized[^].

Some of my past answers are referenced above, I explain what can you do instead.


这篇关于如何在父窗口,C#Windows应用程序中打开子窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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