.NET2.0 WinForms系列(一)实现窗体切分

  1. use

    System.Windows.Forms.SplitContainer MySplitContainer = new System.Windows.Forms.SplitContainer();

  2. initialize

     1            this.SuspendLayout();
     2
     3            splitContainer1.SuspendLayout();
     4
     5            splitContainer1.BorderStyle = BorderStyle.Fixed3D;
     6
     7            splitContainer1.SplitterIncrement = 7;
     8
     9            SplitContainer horizontalSplitter = new SplitContainer();
    10            horizontalSplitter.Name = "horizontal";
    11            horizontalSplitter.Orientation = Orientation.Horizontal;
    12            horizontalSplitter.SuspendLayout();
    13            horizontalSplitter.BorderStyle = BorderStyle.FixedSingle;
    14
    15
    16            splitContainer1.Dock = DockStyle.Fill;
    17
    18            splitContainer1.Panel2.Controls.Add(horizontalSplitter);
    19            horizontalSplitter.Dock = DockStyle.Fill;
    20
    21            splitContainer1.Panel1MinSize = 100;
    22
    23            horizontalSplitter.Panel1.Controls.Add(groupBox1);
    24
    25            groupBox1.Dock = DockStyle.None;
    26
    27            splitContainer1.ResumeLayout();
    28            horizontalSplitter.ResumeLayout();
    29            this.ResumeLayout();

     

  3. Note
    When adding several controls to a parent control, it is recommended that you call the SuspendLayout method before initializing the controls to be added. After adding the controls to the parent control, call the ResumeLayout method. This will increase the performance of applications with many controls.

posted @ 2007-11-26 15:53  许晓光  阅读(290)  评论(0编辑  收藏  举报