Anchor:
一个控件可以锚定到其父容器的一个或多个边缘。将控件锚定到其父容器,可确保当调整父容器的大小时锚定的边缘与父容器的边缘的相对位置保持不变。例如,如果有一个带有 Button 的 Form,而该按钮的 Anchor 属性值设置为 AnchorStyles.Top 和 AnchorStyles.Bottom,当 Form 的 Height 增加时,Button 伸展,以保持到 Form 的上边缘和下边缘的锚定距离不变。dock:
获取或设置控件停靠到父容器的哪一个边缘。一个控件可以停靠到其父容器的一个边缘或者可以停靠到所有边缘并充满父容器。例如,如果将该属性设置为 DockStyle.Left,控件的左边缘将停靠到其父控件的左边缘。其实你在设计中对照着设计成不同的方式就可以看出区别.当属性的说明没显示完,剩下的说明可以这样,将你的属性窗口下面说明的部分按住标题向上托一下就会接着出了.

解决方案 »

  1.   

    以编程方式创建 Outlook 样式的用户界面 声明组成用户界面的每个控件。在本例中,使用 TreeView、ListView、Panel、Splitter 和 RichTextBox 控件模仿 Microsoft Outlook 用户界面。 
    ' Visual Basic
    Private WithEvents treeView1 As System.Windows.Forms.TreeView
    Private WithEvents listView1 As System.Windows.Forms.ListView
    Private WithEvents richTextBox1 As System.Windows.Forms.RichTextBox
    Private WithEvents splitter2 As System.Windows.Forms.Splitter
    Private WithEvents splitter1 As System.Windows.Forms.Splitter
    Private WithEvents panel1 As System.Windows.Forms.Panel// C#
    private System.Windows.Forms.TreeView treeView1;
    private System.Windows.Forms.ListView listView1;
    private System.Windows.Forms.RichTextBox richTextBox1;
    private System.Windows.Forms.Splitter splitter2;
    private System.Windows.Forms.Splitter splitter1;
    private System.Windows.Forms.Panel panel1;
    创建定义用户界面的过程。下面的代码设置属性,使窗体类似于 Microsoft Outlook 中的用户界面。但是,通过使用其他控件或使它们停靠在不同的位置,一样可以轻松创建同样灵活的其他用户界面。 
    ' Visual Basic
    Public Sub OutlookUI()
       ' Create an instance of each control being used.
       Me.components = New System.ComponentModel.Container()
       Me.treeView1 = New System.Windows.Forms.TreeView()
       Me.listView1 = New System.Windows.Forms.ListView()
       Me.richTextBox1 = New System.Windows.Forms.RichTextBox()
       Me.splitter2 = New System.Windows.Forms.Splitter()
       Me.splitter1 = New System.Windows.Forms.Splitter()
       Me.panel1 = New System.Windows.Forms.Panel()   ' Should you develop this into a working application, use the AddHandler method to hook up event procedures here.   ' Set properties of TreeView control.
       ' Use the With statement to avoid repetitive code.
       With Me.treeView1
          .Dock = System.Windows.Forms.DockStyle.Left
          ' Use the relative size to accommodate the possibility of
          ' different units.
          ' Length is irrelevant if you have docked the control to Left.
          .Width = Me.ClientSize.Width \ 3
          .TabIndex = 0
          .Nodes.Add("treeView")
       End With   ' Set properties of ListView control.
       With Me.listView1
          .Dock = System.Windows.Forms.DockStyle.Top
          ' Width is irrelevant when the control is docked to Top.
          .Height = Me.ClientSize.Height * 2 \ 3
          .TabIndex = 0
          .Items.Add("listView")
       End With   ' Set properties of RichTextBox control.
       With Me.richTextBox1
          .Dock = System.Windows.Forms.DockStyle.Fill
          ' The order of the controls in this call is critical.
          ' Width and length are irrelevant when control is docked to Fill.
          .TabIndex = 2
          .Text = "richTextBox1"
       End With   ' Set properties of Panel's Splitter control.
       With Me.splitter2
          .Dock = System.Windows.Forms.DockStyle.Top
          ' Width is irrelevant if splitter is docked to Top.
          .Height = 3
          .TabIndex = 1
          ' Color the splitters to tell them apart.
          .BackColor = Color.Blue
          ' Set TabStop to false for ease of use when negotiating
          ' the user interface.
          .TabStop = False
       End With   ' Set properties of Form's Splitter control.
       With Me.splitter1
          .Location = New System.Drawing.Point(121, 0)
          .Width = 3
          ' Color the splitters to tell them apart.
          .BackColor = Color.Red
          .TabIndex = 1
          ' Set TabStop to false for ease of use when negotiating
          ' the user interface.
          .TabStop = False
       End With   With panel1
          ' Add the appropriate controls to the Panel.
          ' The order of the controls in this call is critical.
          .Controls.AddRange(New System.Windows.Forms.Control() _
             {Me.richTextBox1, Me.splitter2, Me.listView1})      ' Set properties of Panel control.
          .Dock = System.Windows.Forms.DockStyle.Fill
          .TabIndex = 2
       End With   ' Add the rest of the controls to the form.
       ' The order of the controls in this call is critical.
       Me.Controls.AddRange(New System.Windows.Forms.Control() _
          {Me.panel1, Me.splitter1, Me.treeView1})
       Me.Text = "Intricate UI Example"
    End Sub// C#
    public void OutlookUI()
    {
       // Create an instance of each control being used.
       treeView1 = new System.Windows.Forms.TreeView();
       listView1 = new System.Windows.Forms.ListView();
       richTextBox1 = new System.Windows.Forms.RichTextBox();
       splitter2 = new System.Windows.Forms.Splitter();
       splitter1 = new System.Windows.Forms.Splitter();
       panel1 = new System.Windows.Forms.Panel();         
       // Insert code here to hook up event methods.   // Set properties of TreeView control.
       treeView1.Dock = System.Windows.Forms.DockStyle.Left;
       treeView1.Width = this.ClientSize.Width / 3;
       treeView1.TabIndex = 0;
       treeView1.Nodes.Add("treeView");   // Set properties of ListView control.
       listView1.Dock = System.Windows.Forms.DockStyle.Top;
       listView1.Height = this.ClientSize.Height * 2 / 3;
       listView1.TabIndex = 0;
       listView1.Items.Add("listView");   // Set properties of RichTextBox control.
       richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
       richTextBox1.TabIndex = 2;
       richTextBox1.Text = "richTextBox1";   // Set properties of Panel's Splitter control.
       splitter2.Dock = System.Windows.Forms.DockStyle.Top;
       // Width is irrelevant if splitter is docked to Top.
       splitter2.Height = 3;
       // Use a different color to distinguish the two splitters.
       splitter2.BackColor = Color.Blue;
       splitter2.TabIndex = 1;
       // Set TabStop to false for ease of use when negotiating
       // the user interface.
       splitter2.TabStop = false;   // Set properties of Form's Splitter control.
       splitter1.Location = new System.Drawing.Point(121, 0);
       splitter1.Size = new System.Drawing.Size(3, 273);
       splitter1.BackColor = Color.Red;
       splitter1.TabIndex = 1;
       // Set TabStop to false for ease of use when negotiating
       // the user interface.
       splitter1.TabStop = false;   // Add the appropriate controls to the Panel.
       // The order of the controls in this call is critical.
       panel1.Controls.AddRange(new System.Windows.Forms.Control[]
          {richTextBox1, splitter2, listView1});   // Set properties of Panel control.
       panel1.Dock = System.Windows.Forms.DockStyle.Fill;
       panel1.TabIndex = 2;   // Add the rest of the controls to the form.
       // The order of the controls in this call is critical.
       Controls.AddRange(new System.Windows.Forms.Control[]
          {panel1, splitter1, treeView1});
       this.Text = "Intricate UI Example";
    }
    在 Visual Basic 中,添加对刚才在 New() 过程中创建的过程的调用。在 C# 中,将此代码行添加到窗体类的构造函数中。 
    ' Visual Basic
    ' Add this to the New procedure.
    OutlookUI()// C#
    // Add this to the form class's constructor.
    OutlookUI();
    按 F5 键以运行您的应用程序。