Control.Dock 속성

정의

어느 컨트롤 테두리가 부모 컨트롤에 도킹되는지를 가져오거나 설정하고 해당 부모를 기초로 컨트롤 크기를 조정하는 방법을 결정합니다.

public:
 virtual property System::Windows::Forms::DockStyle Dock { System::Windows::Forms::DockStyle get(); void set(System::Windows::Forms::DockStyle value); };
public virtual System.Windows.Forms.DockStyle Dock { get; set; }
member this.Dock : System.Windows.Forms.DockStyle with get, set
Public Overridable Property Dock As DockStyle

속성 값

DockStyle

DockStyle 값 중 하나입니다. 기본값은 None입니다.

예외

할당된 값이 DockStyle 값 중 하나가 아닌 경우

예제

다음 코드 예제에서는 공통 속성 중 일부를 만들고 GroupBox 설정합니다. 이 예에서는 만듭니다는 TextBox 설정 및 해당 Location 그룹 상자 내에서. 그런 다음 설정의 Text 그룹 상자 및 폼의 위쪽에 도킹 된 그룹 상자는 속성입니다. 마지막으로, 그룹 상자를 설정 하 여 비활성화 된 Enabled 속성을 false, 사용 하지 않도록 설정할 그룹 상자 내에 포함 된 모든 컨트롤에 이르게 합니다.

   // 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

설명

부모 컨트롤의 Dock 크기를 조정할 때 컨트롤의 크기를 자동으로 조정 하는 방법을 정의 하려면 속성을 사용 합니다. 예를 들어 컨트롤이 부모 컨트롤의 왼쪽 가장자리에 맞춰지고 부모 컨트롤의 크기가 조정되면 크기가 조정되도록 설정 Dock DockStyle.Left 됩니다. 컨트롤은 폼의 Z축(깊이)을 따라 폼에 있는 컨트롤의 시각적 계층화인 Z 순서로 도킹됩니다.

컨트롤을 부모 컨테이너의 한 가장자리에 도킹하거나 모든 가장자리에 도킹하여 부모 컨테이너를 채울 수 있습니다.

Margin 도킹된 컨트롤에서 속성을 설정해도 컨테이너 가장자리에서 컨트롤의 거리에 영향을 주지 않습니다.

참고

Dock 속성은 Anchor 함께 사용할 수 없습니다. 한 번에 하나만 설정할 수 있으며 마지막 집합이 우선합니다.

상속자 참고

파생 클래스의 Dock 속성을 재정의할 때 기본 클래스의 Dock 속성을 사용하여 기본 구현을 확장합니다. 그렇지 않으면 모든 구현을 제공해야 합니다. 속성의 메서드와 set 메서드를 모두 get 재정의할 필요는 없습니다. 필요한 경우 하나만 재정의 Dock 할 수 있습니다.

적용 대상

추가 정보