AnchorStyles 열거형

정의

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

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

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

필드

Bottom 2

컨트롤이 해당 컨테이너의 아래쪽 가장자리에 앵커로 고정되어 있습니다.

Left 4

컨트롤이 해당 컨테이너의 왼쪽 가장자리에 앵커로 고정되어 있습니다.

None 0

컨트롤이 해당 컨테이너의 가장자리에 앵커로 고정되어 있지 않습니다.

Right 8

컨트롤이 해당 컨테이너의 오른쪽 가장자리에 앵커되어 있습니다.

Top 1

컨트롤이 해당 컨테이너의 위쪽 가장자리에 앵커되어 있습니다.

예제

다음 예제에서는 추가 Button 양식에 해당 공용 속성 중 일부를 설정 합니다. 이 예제에서는 폼 크기가 조정 될 때의 상대적 위치를 유지할 수 있도록 단추를 폼의 오른쪽 아래 모퉁이 고정 합니다. 설정 옆의 BackgroundImage 단추와 같은 크기를 조정 하 고는 Image합니다. 설정한 후 합니다 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 속성이 없음으로 설정 및 Form 크기가 컨트롤에 있는 두 방향에서 20 픽셀 단추 양방향에서 10 픽셀 만큼 이동된 됩니다.

적용 대상

추가 정보