언어

AnchorStyles 열거형

정의

컨트롤이 컨테이너의 가장자리에 고정하는 방법을 지정합니다.

이 열거형은 멤버 값의 비트 조합을 지원합니다.

public enum class AnchorStyles
[System.Flags]
public enum AnchorStyles
[<System.Flags>]
type AnchorStyles = 
Public Enum AnchorStyles
상속
AnchorStyles
특성

필드

속성 값 Description
None 0

컨트롤은 컨테이너의 가장자리에 고정되지 않습니다.

Top 1

컨트롤은 컨테이너의 위쪽 가장자리에 고정됩니다.

Bottom 2

컨트롤은 컨테이너의 아래쪽 가장자리에 고정됩니다.

Left 4

컨트롤은 컨테이너의 왼쪽 가장자리에 고정됩니다.

Right 8

컨트롤은 컨테이너의 오른쪽 가장자리에 고정됩니다.

예제

다음 예제에서는 폼에 Button 추가 하 고 해당 공통 속성 중 일부를 설정 합니다. 이 예제에서는 폼의 오른쪽 아래 모서리에 단추를 고정하여 폼의 크기를 조정할 때 상대적 위치를 유지합니다. 그런 다음 단추를 설정하고 단추의 크기를 .와 같은 크기로 BackgroundImage조정 Image 합니다. 그런 다음 이 예제에서는 to를 TabStoptrue 설정하고 속성을 설정합니다 TabIndex . 마지막으로 단추의 이벤트를 처리하는 Click 이벤트 처리기를 추가합니다. 이 예제에서는 이름이 ImageList있다고 가정합니다imageList1.

   // Add a button to a form and set some of its common properties.
private:
   void AddMyButton()
   {
      // Create a button and add it to the form.
      Button^ button1 = gcnew Button;

      // Anchor the button to the bottom right corner of the form
      button1->Anchor = static_cast<AnchorStyles>(AnchorStyles::Bottom | AnchorStyles::Right);

      // Assign a background image.
      button1->BackgroundImage = imageList1->Images[ 0 ];

      // Specify the layout style of the background image. Tile is the default.
      button1->BackgroundImageLayout = ImageLayout::Center;

      // Make the button the same size as the image.
      button1->Size = button1->BackgroundImage->Size;

      // Set the button's TabIndex and TabStop properties.
      button1->TabIndex = 1;
      button1->TabStop = true;

      // Add a delegate to handle the Click event.
      button1->Click += gcnew System::EventHandler( this, &Form1::button1_Click );

      // Add the button to the form.
      this->Controls->Add( button1 );
   }
// Add a button to a form and set some of its common properties.
private void AddMyButton()
{
   // Create a button and add it to the form.
   Button button1 = new Button();

   // Anchor the button to the bottom right corner of the form
   button1.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right);

   // Assign a background image.
   button1.BackgroundImage = imageList1.Images[0];

   // Specify the layout style of the background image. Tile is the default.
   button1.BackgroundImageLayout = ImageLayout.Center;
   
   // Make the button the same size as the image.
   button1.Size = button1.BackgroundImage.Size;

   // Set the button's TabIndex and TabStop properties.
   button1.TabIndex = 1;
   button1.TabStop = true;

   // Add a delegate to handle the Click event.
   button1.Click += new System.EventHandler(this.button1_Click);

   // Add the button to the form.
   this.Controls.Add(button1);
}
' Add a button to a form and set some of its common properties.
Private Sub AddMyButton()
   ' Create a button and add it to the form.
   Dim button1 As New Button()
   
   ' Anchor the button to the bottom right corner of the form
   button1.Anchor = AnchorStyles.Bottom Or AnchorStyles.Right
   
   ' Assign a background image.
   button1.BackgroundImage = imageList1.Images(0)

   ' Specify the layout style of the background image. Tile is the default.
   button1.BackgroundImageLayout = ImageLayout.Center
   
   ' Make the button the same size as the image.
   button1.Size = button1.BackgroundImage.Size
   
   ' Set the button's TabIndex and TabStop properties.
   button1.TabIndex = 1
   button1.TabStop = True

   ' Add a delegate to handle the Click event.
   AddHandler button1.Click, AddressOf Me.button1_Click
   
   ' Add the button to the form.
   Me.Controls.Add(button1)
End Sub

설명

컨트롤이 컨테이너의 가장자리에 고정되면 컨테이너 크기가 조정될 때 컨트롤과 지정된 에지 사이의 거리가 일정하게 유지됩니다. 예를 들어 컨트롤이 컨테이너의 오른쪽 가장자리에 고정되는 경우 컨테이너 크기가 조정될 때 컨트롤의 오른쪽 가장자리와 컨테이너의 오른쪽 가장자리 사이의 거리는 일정하게 유지됩니다. 컨트롤 가장자리의 조합에 컨트롤을 고정할 수 있습니다. 컨트롤이 컨테이너의 반대쪽 가장자리(예: 위쪽 및 아래쪽)에 고정되는 경우 컨테이너의 크기가 조정될 때 크기가 조정됩니다. 컨트롤의 Anchor 속성이 None으로 설정된 경우 컨트롤은 컨트롤의 컨테이너 크기가 조정되는 거리의 절반을 이동합니다. 예를 들어 속성 Button 이 Anchor None으로 설정되어 있고 Form 컨트롤이 있는 컨트롤의 크기가 어느 방향으로든 20픽셀씩 조정되는 경우 단추는 양방향으로 10픽셀 이동됩니다.

적용 대상

참고 항목