如何使SplitContainer1.Panel2作为所有子窗体的父级? [英] How to make SplitContainer1.Panel2 as Parent For All Child Forms?
问题描述
我有3种形式
Form1作为Mdicontainer
form2
Form3
Form1具有SplitContainer1,Treeview1控件,并且form1正在运行
作为MdiContainer
Treeview1放置在Splitcontainer1.Panel1内,其中Dock为填充
form2-Button1,Button2:
在form1加载事件中,我已经编写了显示Form2的代码
I have 3 forms
Form1 as Mdicontainer
form2
Form3
Form1 has SplitContainer1,Treeview1 Controls and form1 is acting
as MdiContainer
Treeview1 is placed inside Splitcontainer1.Panel1 With Dock as Fill
form2 - Button1,Button2:
in form1 load event i have written the code to show Form2
form2 f = new form2();
f.MdiParent = this;
f.Parent = this.splitContainer1.Panel2;
f.FormBorderStyle = FormBorderStyle.None;
f.ShowInTaskbar = false;
f.Dock = DockStyle.Fill;
f.StartPosition = FormStartPosition.CenterScreen;
f.Show();
它完美地显示了form2.
当我单击Button1(form2)时,我想向Form3展示,就像我如何编写代码以显示Form2一样.
有什么想法让我真诚地知道.
问候,
Pawan.
It shows the form2 Perfectly..
When i click on Button1(form2), i want to show Form3 like how i wrote the code to show form2.
have any idea do let me know sincerely.
Regards,
Pawan.
推荐答案
好,您需要在主(MDI)表单上公开一个方法.人们普遍认为,公开控件本身是不好的做法.
创建一个公共方法,例如AddToPanel(Form f, ?? panelToAddTo)
(或类似的东西),其中包含您发布的代码的版本.
您可以通过其Parent
属性进入主表单.
干杯
Well, you need to expose a method on you main (MDI)form. It''s generally accepted that exposing the controls themselves is bad practice.
Create a public method likeAddToPanel(Form f, ?? panelToAddTo)
(or something similar) that contains a version of the code you posted.
You can get to the main form by it''sParent
property.
Cheers
这篇关于如何使SplitContainer1.Panel2作为所有子窗体的父级?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!