ScrollableControl.DockPaddingEdges 类

定义

确定停靠控件的边界边距。

public: ref class ScrollableControl::DockPaddingEdges : ICloneable
[System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.ScrollableControl+DockPaddingEdgesConverter))]
public class ScrollableControl.DockPaddingEdges : ICloneable
[<System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.ScrollableControl+DockPaddingEdgesConverter))>]
type ScrollableControl.DockPaddingEdges = class
    interface ICloneable
Public Class ScrollableControl.DockPaddingEdges
Implements ICloneable
继承
ScrollableControl.DockPaddingEdges
属性
实现

示例

下面的代码示例使用派生类 Panel。 该示例将按钮停靠在面板控件中,并循环访问 ScrollableControl.DockPaddingEdges 属性,在单击按钮时单独设置每个属性。 此代码要求 Panel 控件和 Button 已在窗体上实例化,并且名为 的 myCounter 类级成员变量已声明为 32 位带符号整数。 应在按钮的 事件上 Click 调用此代码。

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++;
}
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;
 }
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

注解

ScrollableControl.DockPaddingEdges 在停靠控件的给定边缘或所有边缘上创建边距。 可以通过设置以下属性为每个单独的边缘设置此边距的宽度:Bottom、、TopLeftRight。 或者,可以通过设置 All 属性同时将所有边缘设置为相同的宽度。 如果控件的大小对于其容器来说太大,则将调整控件的大小以适应容器中,减去指定的边距宽度。

属性

All

获取或设置停靠控件的所有边缘的边距宽度。

Bottom

获取或设置停靠控件的下边缘的边距宽度。

Left

获取或设置停靠控件的左边缘的边距宽度。

Right

获取或设置停靠控件的右边缘的边距宽度。

Top

获取或设置停靠控件的顶边缘的边距宽度。

方法

Equals(Object)

此 API 支持产品基础结构,不能在代码中直接使用。

确定指定的对象是否等于当前 ScrollableControl.DockPaddingEdges 对象。

GetHashCode()

用作特定类型的哈希函数。

GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()

返回空字符串。

显式接口实现

ICloneable.Clone()

创建作为当前实例副本的新对象。

适用于

另请参阅