다음을 통해 공유


Control.ClientRectangle 속성

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

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
Public ReadOnly Property ClientRectangle As Rectangle
‘사용 방법
Dim instance As Control
Dim value As Rectangle

value = instance.ClientRectangle
public Rectangle ClientRectangle { get; }
public:
property Rectangle ClientRectangle {
    Rectangle get ();
}
/** @property */
public Rectangle get_ClientRectangle ()
public function get ClientRectangle () : Rectangle

속성 값

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

설명

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

클라이언트 좌표는 컨트롤 클라이언트 영역의 왼쪽 위 모퉁이에 상대적이므로 이 속성에서 반환하는 사각형 왼쪽 위 모퉁이의 좌표는 (0,0)입니다. 이 속성을 사용하면 컨트롤 표면에서 그리기 등의 작업을 수행할 때 컨트롤 클라이언트 영역의 크기와 좌표를 구할 수 있습니다.

컨트롤에서의 그리기 작업에 대한 자세한 내용은 Windows Forms 컨트롤 렌더링을 참조하십시오.

예제

다음 코드 예제에서는 폼에 자동 스크롤을 사용하고, 폼의 크기를 조정하며, 폼의 크기가 조정된 후에도 단추가 표시되도록 합니다. 이 예제를 실행하려면 Formbutton2라는 Button이 있어야 합니다.

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
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 void ResizeForm()
{
    // Enable auto-scrolling for the form.
    this.set_AutoScroll(true);
    // Resize the form.
    Rectangle r = this.get_ClientRectangle();
    // Subtract 100 pixels from each side of the Rectangle.
    r.Inflate(-100, -100);
    this.set_Bounds(this.RectangleToScreen(r));
    // Make sure button2 is visible.
    this.ScrollControlIntoView(button2);
} //ResizeForm

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

Control 클래스
Control 멤버
System.Windows.Forms 네임스페이스
ClientSize
DrawMode