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

编程入门 行业动态 更新时间:2024-10-23 11:16:04
本文介绍了如何在父窗口,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.Parent和System.Window.Forms.Control.Controls,但是如果您尝试使一种形式成为另一种形式的子代,则这些属性将失效.将引发异常. 有一种解决方法,但我建议不要使用它.您可以将Form.TopLevel属性分配为false,然后可以将这种形式作为其他形式的子项插入.看起来很难看.如果子窗体具有非客户区,则父窗体将与所有非客户区一起进入父窗体. Windows并非真正设计为使用此类病理性事物.这将违反大多数基本设计原则.同样,这是永远不需要的.对于Form的子级,可以使用其他容器控件,例如Panel,TabControl等. 请查看我过去关于该主题的答案:父级子窗体关系 [ ^ ]. 另请参见: msdn.microsoft/en-us/library/system. windows.forms.form.aspx [ ^ ], msdn.microsoft/en-us/library/system. windows.forms.control.aspx [ ^ ], msdn.microsoft/en-us/library/system. windows.forms.panel.aspx [ ^ ], msdn.microsoft/en-us/library/system. windows.forms.tabcontrol.aspx [ ^ ]. 我没有提到非常不同的关系:MDI父级和MDI子级之间.这是完全不同的故事,但是我不建议使用MDI.即使Microsoft也不建议这样做.您不必折磨头,也不必用这种丑陋的风格吓users用户. 请参阅: en.wikipedia/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: msdn.microsoft/en-us/library/system.windows.forms.form.aspx[^], msdn.microsoft/en-us/library/system.windows.forms.control.aspx[^], msdn.microsoft/en-us/library/system.windows.forms.panel.aspx[^], msdn.microsoft/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: en.wikipedia/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应用程序中打开子窗口

本文发布于:2023-11-11 10:36:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1578183.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:窗口   应用程序   如何在   Windows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!