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

[LocalizableAttribute(true)] public: virtual property DockStyle Dock { DockStyle get (); void set (DockStyle value); }
/** @property */ public DockStyle get_Dock () /** @property */ public void set_Dock (DockStyle value)
DockStyle 値の 1 つ。既定値は None です。


親コントロールのサイズ変更に合わせてコントロールのサイズを自動的に変更する方法を定義するには、Dock プロパティを使用します。たとえば、Dock を DockStyle.Left に設定すると、コントロールが親コントロールの左端に揃えて配置され、親コントロールのサイズの変更に合わせてサイズ変更されます。コントロールは、Z オーダーに基づいてドッキングされます。Z オーダーは、フォーム上に配置された各コントロールの Z 軸 (奥行) 方向の視覚的な重なり合いのことです。
コントロールは、親コンテナの 1 つの端にドッキングすることも、すべての端にドッキングして親コンテナ全体を塗りつぶすこともできます。
![]() |
---|
Anchor プロパティと Dock プロパティは同時には指定できません。いずれか一方のみを設定でき、一度に両方のプロパティを設定した場合は、最後に設定された方が優先されます。 |

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


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

- Control.Dock プロパティのページへのリンク