Control.Location 속성
정의
해당 컨테이너의 왼쪽 위 모퉁이를 기준으로 컨트롤의 왼쪽 위 모퉁이의 좌표를 가져오거나 설정합니다.Gets or sets the coordinates of the upper-left corner of the control relative to the upper-left corner of its container.
public:
property System::Drawing::Point Location { System::Drawing::Point get(); void set(System::Drawing::Point value); };
public System.Drawing.Point Location { get; set; }
member this.Location : System.Drawing.Point with get, set
Public Property Location As Point
속성 값
해당 컨테이너의 왼쪽 위 모퉁이를 기준으로 하여 컨트롤의 왼쪽 위 모퉁이를 나타내는 Point입니다.The Point that represents the upper-left corner of the control relative to the upper-left corner of its container.
예제
다음 코드 예제에서는를 만들고 GroupBox 일부 공용 속성을 설정 합니다.The following code example creates a GroupBox and sets some of its common properties. 이 예에서는 만듭니다는 TextBox 설정 및 해당 Location 그룹 상자 내에서.The example creates a TextBox and sets its Location within the group box. 그런 다음 설정의 Text 그룹 상자 및 폼의 위쪽에 도킹 된 그룹 상자는 속성입니다.Next, it sets the Text property of the group box, and docks the group box to the top of the form. 마지막으로, 그룹 상자를 설정 하 여 비활성화 된 Enabled 속성을 false
, 사용 하지 않도록 설정할 그룹 상자 내에 포함 된 모든 컨트롤에 이르게 합니다.Lastly, it disables the group box by setting the Enabled property to false
, which causes all controls contained within the group box to be disabled.
// Add a GroupBox to a form and set some of its common properties.
private:
void AddMyGroupBox()
{
// Create a GroupBox and add a TextBox to it.
GroupBox^ groupBox1 = gcnew GroupBox;
TextBox^ textBox1 = gcnew TextBox;
textBox1->Location = Point(15,15);
groupBox1->Controls->Add( textBox1 );
// Set the Text and Dock properties of the GroupBox.
groupBox1->Text = "MyGroupBox";
groupBox1->Dock = DockStyle::Top;
// Disable the GroupBox (which disables all its child controls)
groupBox1->Enabled = false;
// Add the Groupbox to the form.
this->Controls->Add( groupBox1 );
}
// Add a GroupBox to a form and set some of its common properties.
private void AddMyGroupBox()
{
// Create a GroupBox and add a TextBox to it.
GroupBox groupBox1 = new GroupBox();
TextBox textBox1 = new TextBox();
textBox1.Location = new Point(15, 15);
groupBox1.Controls.Add(textBox1);
// Set the Text and Dock properties of the GroupBox.
groupBox1.Text = "MyGroupBox";
groupBox1.Dock = DockStyle.Top;
// Disable the GroupBox (which disables all its child controls)
groupBox1.Enabled = false;
// Add the Groupbox to the form.
this.Controls.Add(groupBox1);
}
' Add a GroupBox to a form and set some of its common properties.
Private Sub AddMyGroupBox()
' Create a GroupBox and add a TextBox to it.
Dim groupBox1 As New GroupBox()
Dim textBox1 As New TextBox()
textBox1.Location = New Point(15, 15)
groupBox1.Controls.Add(textBox1)
' Set the Text and Dock properties of the GroupBox.
groupBox1.Text = "MyGroupBox"
groupBox1.Dock = DockStyle.Top
' Disable the GroupBox (which disables all its child controls)
groupBox1.Enabled = False
' Add the Groupbox to the form.
Me.Controls.Add(groupBox1)
End Sub
설명
클래스는 Point 값 형식 ( Structure
struct
Visual c #의 Visual Basic) 이므로 값으로 반환 됩니다. 즉, 속성에 액세스 하는 것은 컨트롤의 왼쪽 위 지점에 대 한 복사본을 반환 합니다.Because the Point class is a value type (Structure
in Visual Basic, struct
in Visual C#), it is returned by value, meaning accessing the property returns a copy of the upper-left point of the control. 따라서 X Y 이 속성에서 반환 된의 또는 속성을 조정 Point 해도 Left Right 컨트롤의,, Top 또는 Bottom 속성 값에는 영향을 주지 않습니다.So, adjusting the X or Y properties of the Point returned from this property will not affect the Left, Right, Top, or Bottom property values of the control. 이러한 속성을 조정 하려면 각 속성 값을 개별적으로 설정 하거나 새를 사용 하 여 속성을 설정 Location Point 합니다.To adjust these properties set each property value individually, or set the Location property with a new Point.
가 이면 Control Form Location 속성 값은 화면 좌표에서의 왼쪽 위 모퉁이를 나타냅니다 Form .If the Control is a Form, the Location property value represents the upper-left corner of the Form in screen coordinates.