DockStyle 列舉

定義

指定控制項停駐的位置和方式。

public enum class DockStyle
public enum DockStyle
type DockStyle = 
Public Enum DockStyle
繼承
DockStyle

欄位

Bottom 2

控制項的底部邊緣停駐到其內含控制項的下方。

Fill 5

所有控制項的邊緣停駐到其內含控制項的所有邊緣,並且適當地調整大小。

Left 3

控制項的左邊緣停駐到其內含控制項的左邊緣。

None 0

控制項未停駐。

Right 4

控制項的右邊緣停駐到其內含控制項的右邊緣。

Top 1

控制項的頂端邊緣停駐到其內含控制項的上方。

範例

下列範例會建立 , GroupBox 並設定其一些通用屬性。 此範例會建立 , TextBox 並在群組方塊中設定其 Location 。 接下來,它會設定 Text 群組方塊的 屬性,並將群組方塊停駐到表單頂端。 最後,它會將 屬性 false 設定 Enabled 為 來停用群組方塊,這會停用群組方塊中包含的所有控制項。

   // Add a GroupBox to a form and set some of its common properties.
private:
   void AddMyGroupBox()
   {
      // Create a GroupBox and add a TextBox to it.
      GroupBox^ groupBox1 = gcnew GroupBox;
      TextBox^ textBox1 = gcnew TextBox;
      textBox1->Location = Point(15,15);
      groupBox1->Controls->Add( textBox1 );

      // Set the Text and Dock properties of the GroupBox.
      groupBox1->Text = "MyGroupBox";
      groupBox1->Dock = DockStyle::Top;

      // Disable the GroupBox (which disables all its child controls)
      groupBox1->Enabled = false;

      // Add the Groupbox to the form.
      this->Controls->Add( groupBox1 );
   }
// Add a GroupBox to a form and set some of its common properties.
private void AddMyGroupBox()
{
   // Create a GroupBox and add a TextBox to it.
   GroupBox groupBox1 = new GroupBox();
   TextBox textBox1 = new TextBox();
   textBox1.Location = new Point(15, 15);
   groupBox1.Controls.Add(textBox1);

   // Set the Text and Dock properties of the GroupBox.
   groupBox1.Text = "MyGroupBox";
   groupBox1.Dock = DockStyle.Top;

   // Disable the GroupBox (which disables all its child controls)
   groupBox1.Enabled = false;

   // Add the Groupbox to the form.
   this.Controls.Add(groupBox1);
}
' Add a GroupBox to a form and set some of its common properties.
Private Sub AddMyGroupBox()
   ' Create a GroupBox and add a TextBox to it.
   Dim groupBox1 As New GroupBox()
   Dim textBox1 As New TextBox()
   textBox1.Location = New Point(15, 15)
   groupBox1.Controls.Add(textBox1)
   
   ' Set the Text and Dock properties of the GroupBox.
   groupBox1.Text = "MyGroupBox"
   groupBox1.Dock = DockStyle.Top
   
   ' Disable the GroupBox (which disables all its child controls)
   groupBox1.Enabled = False
   
   ' Add the Groupbox to the form.
   Me.Controls.Add(groupBox1)
End Sub

備註

當控制項停駐到其容器的邊緣時,它一律會在容器調整大小時,針對該邊緣進行排清。 如果一個以上的控制項停駐到邊緣,控制項會根據其 Z 順序並排顯示;在 Z 順序中較高控制項的位置會比容器邊緣更遠。

如果選取左、右、上或下,控制項的指定和相反邊緣會調整為包含控制項對應邊緣的大小。 如果選取 Fill,控制項的所有四邊都會調整大小,以符合包含控制項的邊緣。

適用於

另請參閱