다음을 통해 공유


Control.Location 속성

정의

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

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 컨테이너의 왼쪽 위 모퉁이를 기준으로 컨트롤의 왼쪽 위 모퉁이를 나타내는 값입니다.

예제

다음 코드 예제에서는 공통 속성 중 일부를 만들고 GroupBox 설정합니다. 이 예제에서는 그룹 상자 내에서 a TextBox 를 만들고 설정합니다 Location . 다음으로 그룹 상자의 속성을 설정하고 Text 그룹 상자를 폼의 맨 위에 도킹합니다. 마지막으로 그룹 상자에 포함된 모든 컨트롤을 사용하지 않도록 설정하는 속성을 false설정하여 그룹 상자를 사용하지 않도록 설정합니다Enabled.

   // 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 클래스는 값 형식(StructureVisual Basic의 struct 경우 Visual C#)이므로 값으로 반환됩니다. 즉, 속성에 액세스하면 컨트롤의 왼쪽 위 점 복사본이 반환됩니다. 따라서 이 속성에서 반환된 X 속성 또는 Y 속성을 조정해도 컨트롤의 Point , Right또는 BottomTop속성 값에 영향을 미치지 Left않습니다. 이러한 속성을 조정하려면 각 속성 값을 개별적으로 설정하거나 새 Point속성으로 속성을 설정합니다Location.

Control 이 값이 FormLocation 면 속성 값은 화면 내 좌표의 왼쪽 위 모서리를 Form 나타냅니다.

적용 대상

추가 정보