共用方式為


ScrollableControl.DockPadding 屬性

定義

取得控制項所有邊的停駐填補設定。

public:
 property System::Windows::Forms::ScrollableControl::DockPaddingEdges ^ DockPadding { System::Windows::Forms::ScrollableControl::DockPaddingEdges ^ get(); };
public System.Windows.Forms.ScrollableControl.DockPaddingEdges DockPadding { get; }
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.ScrollableControl.DockPaddingEdges DockPadding { get; }
member this.DockPadding : System.Windows.Forms.ScrollableControl.DockPaddingEdges
[<System.ComponentModel.Browsable(false)>]
member this.DockPadding : System.Windows.Forms.ScrollableControl.DockPaddingEdges
Public ReadOnly Property DockPadding As ScrollableControl.DockPaddingEdges

屬性值

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

備註

此屬性會控制停駐元件的這個控制項內的框線。

適用於

另請參閱