Windows窗体MDI问题 [英] windows forms MDI issue
本文介绍了Windows窗体MDI问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我有3种形式,例如form1,form2和form3.所以我想这样添加..
form1.controls.add(from2);
form2.controls.add(from3);
有可能吗...
预先感谢
Hello all,
I have 3 forms like form1,form2 and form3. So i want to add like this..
form1.controls.add(from2);
form2.controls.add(from3);
is it possible....
Thanks in advance
推荐答案
是的,有可能,但您不应该这样做. 结果很丑陋,并且违反了预期的窗口用法.
还是想看看所有的丑陋吗?好,我可以解释一下.
首先,表单之间的父/子关系已经完成.如果尝试调用已显示的分配form1.Parent = form2
的方法,则将引发异常.您仍然可以使用属性System.Windows.Forms.Form.TopLevel
强制执行此类错误呼叫-将其分配给false
以便将表单作为子表单.请参阅:
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.toplevel.aspx [ ^ ].
尝试一下它,看看它是如何工作的,但是对于真正的应用程序则永远不要这样做-没有人会对此表示感谢.对于儿童,请使用任何其他控件.
—SA
Yes, it is possible, but you should not do it. The result is ugly and violates intended window usage.
Still want to see all the ugliness? OK, I can explain how.
First of all, the parent/child relationships between forms is done defunct. If you try to call the methods you have shown of assignform1.Parent = form2
, exception will be thrown. You still can force such bad calls using the propertySystem.Windows.Forms.Form.TopLevel
— assign it tofalse
for a form to be done a child. Please see:
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.toplevel.aspx[^].
Try it and see how it works, but never do it for real applications — no one will say thank you for that. For children, use any other controls.
—SA
这篇关于Windows窗体MDI问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文