次の方法で共有


ScrollableControl.DockPadding プロパティ

コントロールのすべての端に対するドッキング埋め込みの設定を取得します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

構文

'宣言
Public ReadOnly Property DockPadding As DockPaddingEdges
'使用
Dim instance As ScrollableControl
Dim value As DockPaddingEdges

value = instance.DockPadding
public DockPaddingEdges DockPadding { get; }
public:
property DockPaddingEdges^ DockPadding {
    DockPaddingEdges^ get ();
}
/** @property */
public DockPaddingEdges get_DockPadding ()
public function get DockPadding () : DockPaddingEdges

プロパティ値

ドッキングされたコントロールのすべての端への埋め込みを表す ScrollableControl.DockPaddingEdges

解説

このプロパティは、ドッキングされているコンポーネントのこのコントロール内部の境界を制御します。

使用例

派生クラス 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++;
}
private void SetDockPadding()
{
    // Dock the button in the panel.
    button1.set_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.get_DockPadding().set_All(0);
            button1.set_Text("Start");
            break;

        case 1 :
            panel1.get_DockPadding().set_Top(10);
            button1.set_Text("Top");
            break;

        case 2 :
            panel1.get_DockPadding().set_Bottom(10);
            button1.set_Text("Bottom");
            break;

        case 3 :
            panel1.get_DockPadding().set_Left(10);
            button1.set_Text("Left");
            break;

        case 4 :
            panel1.get_DockPadding().set_Right(10);
            button1.set_Text("Right");
            break;

        case 5 :
            panel1.get_DockPadding().set_All(20);
            button1.set_Text("All");
            break;
    }

    // Increment the counter.
    myCounter += 1;
} //SetDockPadding

プラットフォーム

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 クラス
ScrollableControl メンバ
System.Windows.Forms 名前空間
ScrollableControl.DockPaddingEdges
Control.Padding プロパティ
Control.Margin プロパティ
ScrollableControl.AutoScrollMargin プロパティ