DockStyle 枚举
指定控件停靠的位置和方式。
**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)
语法
声明
Public Enumeration DockStyle
用法
Dim instance As DockStyle
public enum DockStyle
public enum class DockStyle
public enum DockStyle
public enum DockStyle
成员
成员名称 | 说明 | |
---|---|---|
Bottom | 该控件的下边缘停靠在其包含控件的底部。 | |
Fill | 控件的各个边缘分别停靠在其包含控件的各个边缘,并且适当调整大小。 | |
Left | 该控件的左边缘停靠在其包含控件的左边缘。 | |
None | 该控件未停靠。 | |
Right | 该控件的右边缘停靠在其包含控件的右边缘。 | |
Top | 该控件的上边缘停靠在其包含控件的顶端。 |
备注
当控件停靠到其容器的一条边缘时,调整容器的大小时,始终使控件与那条边缘对齐。如果多个控件停靠到一条边缘,那么这些控件将按照它们的 Z 顺序并排出现,控件在 Z 顺序中的位置越高,距离容器边缘就越远。
如果选择了 Left、Right、Top 或 Bottom,则调整控件的指定边缘和相对边缘的尺寸至包含控件的相应边缘的尺寸。如果选择了 Fill,则调整控件的所有四条边以匹配包含控件的边缘。
示例
下面的示例创建一个 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