我想用MDI做类似的事情,但我不知道怎么做。现在我只有级联模式的孩子。
我一定需要SuspendLayout和ISupportIntialize吗?
我不知道如何使用SuspendLayout和ISupportIntialize或FixedPanel。所以我这样做:)
http://i.stack.imgur.com/Wltvd.png
对于1/2/3/4面板显示模式之间的自动检查,我尝试使用[选择案例]。
public partial class MainForm : Form
{
Child1Form1 Test1 = new Child1Form1();
Child1Form2 Test2 = new Child1Form2();
Child1Form3 Test3 = new Child1Form3();
Child1Form4 Test4 = new Child1Form4();
public MainForm()
{
InitializeComponent();
this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
this.SizeGripStyle = SizeGripStyle.Show;
//
// splitContainer1
//
//this.splitContainer1.Dock = DockStyle.Fill;
this.splitContainer1.FixedPanel = FixedPanel.Panel1;
this.splitContainer1.FixedPanel = FixedPanel.Panel2;
this.splitContainer1.Panel1.Controls.Add(splitContainer2);
this.splitContainer1.Panel2.Controls.Add(splitContainer3);
//
// splitContainer2
//
//this.splitContainer2.Dock = DockStyle.Fill;
this.splitContainer2.FixedPanel = FixedPanel.Panel1;
this.splitContainer2.FixedPanel = FixedPanel.Panel2;
this.splitContainer2.Panel1.Controls.Add(Test1);
this.splitContainer2.Panel2.Controls.Add(Test2);
//
// splitContainer3
//
//splitContainer3.Dock = DockStyle.Fill;
this.splitContainer3.Panel1.Controls.Add(Test3);
this.splitContainer3.Panel2.Controls.Add(Test4);
this.Test1.Dock = DockStyle.Fill;
this.Test2.Dock = DockStyle.Fill;
this.Test3.Dock = DockStyle.Fill;
this.Test4.Dock = DockStyle.Fill;
}
private void Form1_Load(object sender, EventArgs e)
{
this.Test1.Show();
this.Test2.Show();
this.Test3.Show();
this.Test4.Show();
}
private void splitContainer1_Resize(object sender, EventArgs e)
{
this.Test1.Dock = DockStyle.Fill;
this.Test2.Dock = DockStyle.Fill;
this.Test3.Dock = DockStyle.Fill;
this.Test4.Dock = DockStyle.Fill;
}
答案 0 :(得分:0)
一种方法:在ChildForm1-4的情况下,向表单添加一个SplitContainer
,然后在第一个拆分容器的每个面板中添加两个SplitContainer
并设置{ {1}}到Orientation
。当Designer完成后,您的Horizontal
方法看起来应该是这样的:
InitializeComponent
如果是ChildForm1-3,请在表单中添加一个 private void InitializeComponent()
{
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
this.splitContainer3 = new System.Windows.Forms.SplitContainer();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
this.splitContainer2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).BeginInit();
this.splitContainer3.SuspendLayout();
this.SuspendLayout();
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Name = "splitContainer1";
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.splitContainer2);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.splitContainer3);
this.splitContainer1.Size = new System.Drawing.Size(678, 410);
this.splitContainer1.SplitterDistance = 226;
this.splitContainer1.TabIndex = 0;
//
// splitContainer2
//
this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer2.Location = new System.Drawing.Point(0, 0);
this.splitContainer2.Name = "splitContainer2";
this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal;
this.splitContainer2.Size = new System.Drawing.Size(226, 410);
this.splitContainer2.SplitterDistance = 75;
this.splitContainer2.TabIndex = 0;
//
// splitContainer3
//
this.splitContainer3.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer3.Location = new System.Drawing.Point(0, 0);
this.splitContainer3.Name = "splitContainer3";
this.splitContainer3.Orientation = System.Windows.Forms.Orientation.Horizontal;
this.splitContainer3.Size = new System.Drawing.Size(448, 410);
this.splitContainer3.SplitterDistance = 149;
this.splitContainer3.TabIndex = 0;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(678, 410);
this.Controls.Add(this.splitContainer1);
this.Name = "Form1";
this.Text = "Form1";
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
this.splitContainer2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).EndInit();
this.splitContainer3.ResumeLayout(false);
this.ResumeLayout(false);
}
,然后将SplitContainer
设置为Orientation
,然后将另一个Horizontal
添加到顶部面板并离开{ {1}} SplitContainer
。当Designer完成后,您的Orientation
方法看起来应该是这样的:
Vertical