Control.Dock 속성

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

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
<LocalizableAttribute(True)> _
Public Overridable Property Dock As DockStyle
‘사용 방법
Dim instance As Control
Dim value As DockStyle

value = instance.Dock

instance.Dock = value
[LocalizableAttribute(true)] 
public virtual DockStyle Dock { get; set; }
[LocalizableAttribute(true)] 
public:
virtual property DockStyle Dock {
    DockStyle get ();
    void set (DockStyle value);
}
/** @property */
public DockStyle get_Dock ()

/** @property */
public void set_Dock (DockStyle value)
public function get Dock () : DockStyle

public function set Dock (value : DockStyle)

속성 값

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

예외

예외 형식 조건

InvalidEnumArgumentException

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

설명

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

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

참고

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

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

예제

다음 코드 예제에서는 GroupBox를 만들고 해당 공용 속성 중 일부를 설정합니다. 이 예제에서는 TextBox를 만든 다음 텍스트 상자의 Location을 그룹 상자 내에 설정합니다. 다음에는 그룹 상자의 Text 속성을 설정하고 폼의 상단에 그룹 상자를 도킹시킵니다. 마지막으로 Enabled 속성을 false로 설정하여 그룹 상자를 비활성화합니다. 이렇게 하면 그룹 상자에 포함된 모든 컨트롤도 비활성화됩니다.

' 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
// 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:
   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.set_Location(new Point(15, 15));
    groupBox1.get_Controls().Add(textBox1);
    // Set the Text and Dock properties of the GroupBox.
    groupBox1.set_Text("MyGroupBox");
    groupBox1.set_Dock(DockStyle.Top);
    // Disable the GroupBox (which disables all its child controls)
    groupBox1.set_Enabled(false);
    // Add the Groupbox to the form.
    this.get_Controls().Add(groupBox1);
} //AddMyGroupBox

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0에서 지원

참고 항목

참조

Control 클래스
Control 멤버
System.Windows.Forms 네임스페이스
DockStyle
Control.Anchor 속성
ScrollableControl.DockPaddingEdges
Layout