Control.ClientRectangle 속성

정의

컨트롤의 클라이언트 영역을 나타내는 사각형을 가져옵니다.

public:
 property System::Drawing::Rectangle ClientRectangle { System::Drawing::Rectangle get(); };
[System.ComponentModel.Browsable(false)]
public System.Drawing.Rectangle ClientRectangle { get; }
[<System.ComponentModel.Browsable(false)>]
member this.ClientRectangle : System.Drawing.Rectangle
Public ReadOnly Property ClientRectangle As Rectangle

속성 값

Rectangle

컨트롤의 클라이언트 영역을 나타내는 Rectangle입니다.

특성

예제

다음 코드 예제에서는 폼에 대해 자동 스크롤을 사용하도록 설정하고, 폼의 크기를 조정하며, 폼의 크기를 조정한 후에도 단추가 표시되는지 확인합니다. 이 예제에서는 명명된 Form 항목 button2Button 있어야 합니다.

private:
   void ResizeForm()
   {
      
      // Enable auto-scrolling for the form.
      this->AutoScroll = true;
      
      // Resize the form.
      Rectangle r = this->ClientRectangle;
      
      // Subtract 100 pixels from each side of the Rectangle.
      r.Inflate(  -100, -100 );
      this->Bounds = this->RectangleToScreen( r );
      
      // Make sure button2 is visible.
      this->ScrollControlIntoView( button2 );
   }
private void ResizeForm()
{
   // Enable auto-scrolling for the form.
   this.AutoScroll = true;

   // Resize the form.
   Rectangle r = this.ClientRectangle;
   // Subtract 100 pixels from each side of the Rectangle.
   r.Inflate(-100, -100);
   this.Bounds = this.RectangleToScreen(r);

   // Make sure button2 is visible.
   this.ScrollControlIntoView(button2);
}
Private Sub ResizeForm()
   ' Enable auto-scrolling for the form.
   Me.AutoScroll = True
   
   ' Resize the form.
   Dim r As Rectangle = Me.ClientRectangle
   ' Subtract 100 pixels from each side of the Rectangle.
   r.Inflate(- 100, - 100)
   Me.Bounds = Me.RectangleToScreen(r)
   
   ' Make sure button2 is visible.
   Me.ScrollControlIntoView(button2)
End Sub

설명

컨트롤의 클라이언트 영역은 스크롤 막대, 테두리, 제목 표시줄 및 메뉴와 같은 비클라이언트 요소를 뺀 컨트롤의 범위입니다.

클라이언트 좌표는 컨트롤의 클라이언트 영역의 왼쪽 위 모서리를 기준으로 하기 때문에 이 속성에서 반환된 사각형의 왼쪽 위 모서리 좌표는 (0,0)입니다. 이 속성을 사용 하 여 컨트롤의 표면에 그리기와 같은 작업에 대 한 컨트롤의 클라이언트 영역의 크기와 좌표를 가져올 수 있습니다.

컨트롤에 그리기에 대한 자세한 내용은 Windows Forms 컨트롤 렌더링을 참조하세요.

적용 대상

추가 정보