Control.Bounds 속성

정의

부모 컨트롤을 기준으로 비클라이언트 요소를 포함하는 컨트롤의 크기와 위치(픽셀)를 가져오거나 설정합니다.

public:
 property System::Drawing::Rectangle Bounds { System::Drawing::Rectangle get(); void set(System::Drawing::Rectangle value); };
[System.ComponentModel.Browsable(false)]
public System.Drawing.Rectangle Bounds { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.Bounds : System.Drawing.Rectangle with get, set
Public Property Bounds As Rectangle

속성 값

Rectangle

부모 컨트롤을 기준으로 비클라이언트 요소를 포함하여 컨트롤의 크기와 위치를 나타내는 Rectangle(픽셀)입니다.

특성

예제

다음 코드 예제에서는 폼에 세 Button 개의 컨트롤을 만들고 다양 한 크기 관련 및 위치 관련 속성을 사용 하 여 해당 크기와 위치를 설정 합니다. 이 예제에서는 Form 너비와 높이가 300픽셀 이상인 것이 필요합니다.

// Create three buttons and place them on a form using
// several size and location related properties.
void AddOKCancelButtons()
{
   
   // Set the button size and location using
   // the Size and Location properties.
   Button^ buttonOK = gcnew Button;
   buttonOK->Location = Point(136,248);
   buttonOK->Size = System::Drawing::Size( 75, 25 );
   
   // Set the Text property and make the
   // button the form's default button.
   buttonOK->Text = "&OK";
   this->AcceptButton = buttonOK;
   
   // Set the button size and location using the Top,
   // Left, Width, and Height properties.
   Button^ buttonCancel = gcnew Button;
   buttonCancel->Top = buttonOK->Top;
   buttonCancel->Left = buttonOK->Right + 5;
   buttonCancel->Width = buttonOK->Width;
   buttonCancel->Height = buttonOK->Height;
   
   // Set the Text property and make the
   // button the form's cancel button.
   buttonCancel->Text = "&Cancel";
   this->CancelButton = buttonCancel;
   
   // Set the button size and location using
   // the Bounds property.
   Button^ buttonHelp = gcnew Button;
   buttonHelp->Bounds = Rectangle(10,10,75,25);
   
   // Set the Text property of the button.
   buttonHelp->Text = "&Help";
   
   // Add the buttons to the form.
   array<Control^>^temp1 = {buttonOK,buttonCancel,buttonHelp};
   this->Controls->AddRange( temp1 );
}
// Create three buttons and place them on a form using 
// several size and location related properties. 
private void AddOKCancelButtons()
{
   // Set the button size and location using 
   // the Size and Location properties.
   Button buttonOK = new Button();
   buttonOK.Location = new Point(136,248);
   buttonOK.Size = new Size(75,25);
   // Set the Text property and make the 
   // button the form's default button. 
   buttonOK.Text = "&OK";
   this.AcceptButton = buttonOK;

   // Set the button size and location using the Top, 
   // Left, Width, and Height properties.
   Button buttonCancel = new Button();
   buttonCancel.Top = buttonOK.Top;
   buttonCancel.Left = buttonOK.Right + 5;
   buttonCancel.Width = buttonOK.Width;
   buttonCancel.Height = buttonOK.Height;
   // Set the Text property and make the 
   // button the form's cancel button.
   buttonCancel.Text = "&Cancel";
   this.CancelButton = buttonCancel;

   // Set the button size and location using 
   // the Bounds property.
   Button buttonHelp = new Button();
   buttonHelp.Bounds = new Rectangle(10,10, 75, 25);
   // Set the Text property of the button.
   buttonHelp.Text = "&Help";

   // Add the buttons to the form.
   this.Controls.AddRange(new Control[] {buttonOK, buttonCancel, buttonHelp} );
}
' Create three buttons and place them on a form using 
' several size and location related properties. 
Private Sub AddOKCancelButtons()
   ' Set the button size and location using 
      ' the Size and Location properties. 
   Dim buttonOK As New Button()
   buttonOK.Location = New Point(136, 248)
   buttonOK.Size = New Size(75, 25)
   ' Set the Text property and make the 
   ' button the form's default button. 
   buttonOK.Text = "&OK"
   Me.AcceptButton = buttonOK
   
   ' Set the button size and location using the Top, 
   ' Left, Width, and Height properties. 
   Dim buttonCancel As New Button()
   buttonCancel.Top = buttonOK.Top
   buttonCancel.Left = buttonOK.Right + 5
   buttonCancel.Width = buttonOK.Width
   buttonCancel.Height = buttonOK.Height
   ' Set the Text property and make the 
   ' button the form's cancel button. 
   buttonCancel.Text = "&Cancel"
   Me.CancelButton = buttonCancel
   
   ' Set the button size and location using 
   ' the Bounds property. 
   Dim buttonHelp As New Button()
   buttonHelp.Bounds = New Rectangle(10, 10, 75, 25)
   ' Set the Text property of the button.
   buttonHelp.Text = "&Help"
   
   ' Add the buttons to the form.
   Me.Controls.AddRange(New Control() {buttonOK, buttonCancel, buttonHelp})
End Sub

설명

컨트롤의 경계에는 스크롤 막대, 테두리, 제목 표시줄 및 메뉴와 같은 비클라이언트 요소가 포함됩니다. 속성을 SetBoundsCore 설정하기 위해 메서드가 호출됩니다 Bounds . 속성이 Bounds 메서드를 통해 set 항상 변경되지는 않으므로 속성을 설정할 때 코드가 실행되도록 메서드를 재정 SetBoundsCoreBounds 해야 합니다.

적용 대상

추가 정보