2013-12-11 91 views
-1

我想用MDI做類似的事情,但我不知道如何。現在我只有孩子在級聯模式。MDI兒童表格沒有自由空間

enter image description here


我可是從聖誕節回來,從我的家鄉,每天開始工作。 :)

我一定需要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

propestipes.DOCK但meyby我必須結合更多的,我不知道現在。 – Vanguard1990

+0

好吧,顯然你不想要MDI。 WeiFen Luo的DockPanelSuite很受歡迎,價格合適。 –

+0

彼得已經給出了一個答案,可以爲您提供靈感/解決方案,如果您使用WinForms。如果您使用WPF而不是WinForms,請讓我們知道... – elgonzo

回答

0

一種方式做到這一點:在ChildForm1-4的情況下,添加一個SplitContainer到窗體,然後在每個第一分割容器的面板添加兩個SplitContainer S和設置OrientationHorizontal。你InitializeComponent方法應該是這個樣子,當設計完成:

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); 

    } 

在ChildForm1-3的情況下,添加一個SplitContainer的形式和設置OrientationHorizontal再加入另一SplitContainer到頂部面板和離開OrientationVertical。你InitializeComponent方法應該是這個樣子,當設計完成:

private void InitializeComponent() 
    { 
     this.splitContainer1 = new System.Windows.Forms.SplitContainer(); 
     this.splitContainer2 = new System.Windows.Forms.SplitContainer(); 
     ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); 
     this.splitContainer1.Panel1.SuspendLayout(); 
     this.splitContainer1.SuspendLayout(); 
     ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit(); 
     this.splitContainer2.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"; 
     this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; 
     // 
     // splitContainer1.Panel1 
     // 
     this.splitContainer1.Panel1.Controls.Add(this.splitContainer2); 
     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.Size = new System.Drawing.Size(678, 226); 
     this.splitContainer2.SplitterDistance = 226; 
     this.splitContainer2.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); 
     ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); 
     this.splitContainer1.ResumeLayout(false); 
     ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit(); 
     this.splitContainer2.ResumeLayout(false); 
     this.ResumeLayout(false); 

    }