다음을 통해 공유


Control.Location 속성

해당 컨테이너의 왼쪽 위 모퉁이를 기준으로 컨트롤의 왼쪽 위 모퉁이의 좌표를 가져오거나 설정합니다.

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

구문

‘선언
<LocalizableAttribute(True)> _
Public Property Location As Point
‘사용 방법
Dim instance As Control
Dim value As Point

value = instance.Location

instance.Location = value
[LocalizableAttribute(true)] 
public Point Location { get; set; }
[LocalizableAttribute(true)] 
public:
property Point Location {
    Point get ();
    void set (Point value);
}
/** @property */
public Point get_Location ()

/** @property */
public void set_Location (Point value)
public function get Location () : Point

public function set Location (value : Point)

속성 값

해당 컨테이너의 왼쪽 위 모퉁이를 기준으로 하여 컨트롤의 왼쪽 위 모퉁이를 나타내는 Point입니다.

설명

Point 클래스는 값 형식(Visual Basic의 경우 Structure, Visual C#의 경우 struct)이므로 값으로 반환됩니다. 즉, 이 속성에 액세스하면 컨트롤의 왼쪽 위 지점의 복사본이 반환됩니다. 따라서 이 속성에서 반환하는 PointX 또는 Y 속성을 조정해도 컨트롤의 Left, Right, Top 또는 Bottom 속성 값에 영향을 주지 않습니다. 이러한 속성을 조정하려면 각 속성 값을 개별적으로 설정하거나 새 Point를 사용하여 Location 속성을 설정합니다.

ControlForm이면 Location 속성 값은 화면 좌표에서 Form의 왼쪽 위 모퉁이를 나타냅니다.

예제

다음 코드 예제에서는 GroupBox를 만들고 해당 공용 속성 중 일부를 설정합니다. 이 예제에서는 TextBox를 만든 다음 텍스트 상자의 Location을 그룹 상자 내에 설정합니다. 다음에는 그룹 상자의 Text 속성을 설정하고 폼의 상단에 그룹 상자를 도킹시킵니다. 마지막으로 Enabled 속성을 false로 설정하여 그룹 상자를 비활성화합니다. 이렇게 하면 그룹 상자에 포함된 모든 컨트롤도 비활성화됩니다.

' 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
// 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:
   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.set_Location(new Point(15, 15));
    groupBox1.get_Controls().Add(textBox1);
    // Set the Text and Dock properties of the GroupBox.
    groupBox1.set_Text("MyGroupBox");
    groupBox1.set_Dock(DockStyle.Top);
    // Disable the GroupBox (which disables all its child controls)
    groupBox1.set_Enabled(false);
    // Add the Groupbox to the form.
    this.get_Controls().Add(groupBox1);
} //AddMyGroupBox

플랫폼

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 네임스페이스
Form
ContainerControl 클래스

기타 리소스

Windows Forms 좌표