Control.Location プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

[LocalizableAttribute(true)] public: property Point Location { Point get (); void set (Point value); }
/** @property */ public Point get_Location () /** @property */ public void set_Location (Point value)
コントロールの左上隅をコンテナの左上隅に対して相対的に表す Point。

Point クラスは値型 (Visual Basic では Structure、Visual C# では struct) であるため、値で返されます。つまり、このプロパティにアクセスすると、コントロールの左上隅のコピーが返されます。したがって、このプロパティから返された Point の X プロパティまたは Y プロパティを調整しても、コントロールの Left、Right、Top、または Bottom の各プロパティ値に影響はありません。これらのプロパティを調整するには、各プロパティ値を個別に設定するか、または新しい Point で Location プロパティを設定します。

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ControlLocation 列挙体
アセンブリ: System.Design (system.design.dll 内)

Public Enumeration ControlLocation

メンバ名 | 説明 | |
---|---|---|
After | 現在選択されているコントロール (つまり現在のコントロール) の後にコントロールを追加します。 | |
Before | 現在選択されているコントロール (つまり現在のコントロール) の前にコントロールを追加します。 | |
First | ドキュメントの先頭にコントロールを追加します。 | |
FirstChild | 選択されているコントロールがコンテナ コントロールである場合、選択されているコントロールの最初の子としてコントロールを追加します。 | |
Last | ドキュメントの末尾にコントロールを追加します。 | |
LastChild | 選択されているコントロールがコンテナ コントロールである場合、選択されているコントロールの最後の子としてコントロールを追加します。 |


Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からControl.Locationを検索する場合は、下記のリンクをクリックしてください。

- Control.Locationのページへのリンク