Control.Bounds 속성

정의

부모 컨트롤을 기준으로 비클라이언트 요소를 포함하는 컨트롤의 크기와 위치(픽셀)를 가져오거나 설정합니다.Gets or sets the size and location of the control including its nonclient elements, in pixels, relative to the parent control.

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; }
member this.Bounds : System.Drawing.Rectangle with get, set
Public Property Bounds As Rectangle

속성 값

부모 컨트롤을 기준으로 비클라이언트 요소를 포함하여 컨트롤의 크기와 위치를 나타내는 Rectangle(픽셀)입니다.A Rectangle in pixels relative to the parent control that represents the size and location of the control including its nonclient elements.

특성

예제

다음 코드 예제에서는 폼에 대해 3 개의 Button 컨트롤을 만들고 다양 한 크기 관련 및 위치 관련 속성을 사용 하 여 크기와 위치를 설정 합니다.The following code example creates three Button controls on a form and sets their size and location by using the various size-related and location-related properties. 이 예제에서는 너비와 높이가 300 픽셀 이상인 Form 있어야 합니다.This example requires that you have a Form that has a width and height of at least 300 pixels.

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

설명

컨트롤의 범위는 스크롤 막대, 테두리, 제목 표시줄 및 메뉴와 같은 비클라이언트 요소를 포함 합니다.The bounds of the control include the nonclient elements such as scroll bars, borders, title bars, and menus. SetBoundsCore 메서드를 호출 하 여 Bounds 속성을 설정 합니다.The SetBoundsCore method is called to set the Bounds property. Bounds 속성은 항상 set 메서드를 통해 변경 되지 않으므로 Bounds 속성이 설정 될 때 코드가 실행 되도록 SetBoundsCore 메서드를 재정의 해야 합니다.The Bounds property is not always changed through its set method so you should override the SetBoundsCore method to ensure that your code is executed when the Bounds property is set.

적용 대상

추가 정보