영어로 읽기

다음을 통해 공유


Control.SetBounds 메서드

정의

컨트롤의 범위를 설정합니다.

오버로드

SetBounds(Int32, Int32, Int32, Int32)

컨트롤의 범위를 지정된 위치와 크기로 설정합니다.

SetBounds(Int32, Int32, Int32, Int32, BoundsSpecified)

컨트롤의 지정된 범위를 특정 위치와 크기로 설정합니다.

SetBounds(Int32, Int32, Int32, Int32)

컨트롤의 범위를 지정된 위치와 크기로 설정합니다.

public void SetBounds (int x, int y, int width, int height);

매개 변수

x
Int32

컨트롤의 새 Left 속성 값입니다.

y
Int32

컨트롤의 새 Top 속성 값입니다.

width
Int32

컨트롤의 새 Width 속성 값입니다.

height
Int32

컨트롤의 새 Height 속성 값입니다.

추가 정보

적용 대상

.NET Framework 4.8.1 및 기타 버전
제품 버전
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

SetBounds(Int32, Int32, Int32, Int32, BoundsSpecified)

컨트롤의 지정된 범위를 특정 위치와 크기로 설정합니다.

public void SetBounds (int x, int y, int width, int height, System.Windows.Forms.BoundsSpecified specified);

매개 변수

x
Int32

컨트롤의 새 Left 속성 값입니다.

y
Int32

컨트롤의 새 Top 속성 값입니다.

width
Int32

컨트롤의 새 Width 속성 값입니다.

height
Int32

컨트롤의 새 Height 속성 값입니다.

specified
BoundsSpecified

BoundsSpecified 값의 비트 조합입니다. 매개 변수를 지정하지 않으면 현재 값이 사용됩니다.

예제

다음 코드 예제에서는 이벤트의 화면에 을 가운데 Form 에 표시합니다 Layout . 이렇게 하면 양식의 크기가 조정될 때 양식이 가운데에 유지됩니다. 이 예제에서는 컨트롤을 만들어야 합니다 Form .

private void MyForm_Layout(object sender, System.Windows.Forms.LayoutEventArgs e)
{
   // Center the Form on the user's screen everytime it requires a Layout.
   this.SetBounds((Screen.GetBounds(this).Width/2) - (this.Width/2),
       (Screen.GetBounds(this).Height/2) - (this.Height/2),
       this.Width, this.Height, BoundsSpecified.Location);	
}

추가 정보

적용 대상

.NET Framework 4.8.1 및 기타 버전
제품 버전
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9