Control.Location Özellik

Tanım

Denetimin sol üst köşesinin koordinatlarını kapsayıcısının sol üst köşesine göre alır veya ayarlar.

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

Özellik Değeri

kapsayıcısının Point sol üst köşesine göre denetimin sol üst köşesini temsil eden.

Örnekler

Aşağıdaki kod örneği bir GroupBox oluşturur ve ortak özelliklerinden bazılarını ayarlar. Örnek, grup kutusu içinde bir TextBox oluşturur ve ayarlar Location . Ardından, grup kutusunun özelliğini ayarlar Text ve grup kutusunu formun en üstüne sabitler. Son olarak, özelliğini falseolarak ayarlayarak Enabled grup kutusunu devre dışı bırakır ve bu da grup kutusunun içindeki tüm denetimlerin devre dışı bırakılmasına neden olur.

   // 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

Açıklamalar

Point sınıfı bir değer türü olduğundan (StructureVisual Basic'te, struct Visual C# içinde), değer tarafından döndürülür, yani özelliğe erişmek denetimin sol üst noktasının bir kopyasını döndürür. Bu nedenle, bu özellikten döndürülen veya Y özelliklerinin Point ayarlanması X denetimin Left, Right, Topveya Bottom özellik değerlerini etkilemez. Bu özellikleri ayarlamak için her özellik değerini ayrı ayrı ayarlayın veya özelliği yeni Pointbir ile ayarlayınLocation.

ControlFormise, Location özellik değeri ekran koordinatlarında öğesinin sol üst köşesini Form temsil eder.

Şunlara uygulanır

Ayrıca bkz.