ScrollableControl.DockPaddingEdges 类
确定停靠控件的边界边距。
**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)
语法
声明
Public Class DockPaddingEdges
Implements ICloneable
用法
Dim instance As DockPaddingEdges
public class DockPaddingEdges : ICloneable
public ref class DockPaddingEdges : ICloneable
public class DockPaddingEdges implements ICloneable
public class DockPaddingEdges implements ICloneable
备注
ScrollableControl.DockPaddingEdges 类创建停靠控件的给定边缘或所有边缘的边距。可以通过设置下列属性来为每个单独边缘设置此边距宽度:Bottom、Top、Left、Right。或者,也可以通过设置 All 属性将所有边缘设置为同一宽度。如果控件的大小对其容器来说太大,则将重新调整该控件的大小以便与容器相适应,减去指定的边距宽度。
示例
下面的代码示例使用派生类 Panel。该示例在面板控件中停靠一个按钮,并通过单击按钮来逐一设置 ScrollableControl.DockPaddingEdges 属性,从而循环通过这些属性。此代码要求已在窗体上实例化了一个 Panel 控件和一个 Button,并已将一个名为 myCounter
的类级成员变量声明为 32 位有符号整数。应该对按钮的 Click 事件调用此代码。
Private Sub SetDockPadding()
' Dock the button in the panel.
button1.Dock = System.Windows.Forms.DockStyle.Fill
' Reset the counter if it is greater than 5.
If myCounter > 5 Then
myCounter = 0
End If
' Set the appropriate DockPadding and display
' which one was set on the button face.
Select Case myCounter
Case 0
panel1.DockPadding.All = 0
button1.Text = "Start"
Case 1
panel1.DockPadding.Top = 10
button1.Text = "Top"
Case 2
panel1.DockPadding.Bottom = 10
button1.Text = "Bottom"
Case 3
panel1.DockPadding.Left = 10
button1.Text = "Left"
Case 4
panel1.DockPadding.Right = 10
button1.Text = "Right"
Case 5
panel1.DockPadding.All = 20
button1.Text = "All"
End Select
' Increment the counter.
myCounter += 1
End Sub
private void SetDockPadding()
{
// Dock the button in the panel.
button1.Dock = System.Windows.Forms.DockStyle.Fill;
// Reset the counter if it is greater than 5.
if (myCounter > 5)
{
myCounter = 0;
}
/* Set the appropriate DockPadding and display
which one was set on the button face. */
switch (myCounter)
{
case 0:
panel1.DockPadding.All = 0;
button1.Text = "Start";
break;
case 1:
panel1.DockPadding.Top = 10;
button1.Text = "Top";
break;
case 2:
panel1.DockPadding.Bottom = 10;
button1.Text = "Bottom";
break;
case 3:
panel1.DockPadding.Left = 10;
button1.Text = "Left";
break;
case 4:
panel1.DockPadding.Right = 10;
button1.Text = "Right";
break;
case 5:
panel1.DockPadding.All = 20;
button1.Text = "All";
break;
}
// Increment the counter.
myCounter += 1;
}
void SetDockPadding()
{
// Dock the button in the panel.
button1->Dock = System::Windows::Forms::DockStyle::Fill;
// Reset the counter if it is greater than 5.
if ( myCounter > 5 )
{
myCounter = 0;
}
/* Set the appropriate DockPadding and display
which one was set on the button face. */
switch ( myCounter )
{
case 0:
panel1->DockPadding->All = 0;
button1->Text = "Start";
break;
case 1:
panel1->DockPadding->Top = 10;
button1->Text = "Top";
break;
case 2:
panel1->DockPadding->Bottom = 10;
button1->Text = "Bottom";
break;
case 3:
panel1->DockPadding->Left = 10;
button1->Text = "Left";
break;
case 4:
panel1->DockPadding->Right = 10;
button1->Text = "Right";
break;
case 5:
panel1->DockPadding->All = 20;
button1->Text = "All";
break;
}
myCounter++;
}
继承层次结构
System.Object
System.Windows.Forms.ScrollableControl.DockPaddingEdges
线程安全
此类型的任何公共静态(Visual Basic 中的 Shared)成员都是线程安全的,但不保证所有实例成员都是线程安全的。
平台
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
请参见
参考
ScrollableControl.DockPaddingEdges 成员
System.Windows.Forms 命名空间
ScrollableControl 类