通过设置 Dock 属性,可以使控件与窗体边缘对齐。此属性指定控件在窗体中的驻留位置。可以将 Dock 属性设置为下列值:
在 Visual Studio 中,对此功能提供设计时支持。
在运行时设置控件的 Dock 属性
-
可在代码中将 Dock 属性设置为适当的值。
' To set the Dock property internally.
Me.Dock = DockStyle.Top
' To set the Dock property from another object.
UserControl1.Dock = DockStyle.Top
// To set the Dock property internally.
this.Dock = DockStyle.Top;
// To set the Dock property from another object.
UserControl1.Dock = DockStyle.Top;
// To set the Dock property internally.
this.set_Dock(DockStyle.Top);
// To set the Dock property from another object.
UserControl1.set_Dock(DockStyle.Top);
请参见