Export (0) Print
Expand All

ScrollableControl.DockPaddingEdges Class

Determines the border padding for docked controls.

For a list of all members of this type, see ScrollableControl.DockPaddingEdges Members.

System.Object
   System.Windows.Forms.ScrollableControl.DockPaddingEdges

[Visual Basic]
Public Class ScrollableControl.DockPaddingEdges
   Implements ICloneable
[C#]
public class ScrollableControl.DockPaddingEdges : ICloneable
[C++]
public __gc class ScrollableControl.DockPaddingEdges : public
   ICloneable
[JScript]
public class ScrollableControl.DockPaddingEdges implements
   ICloneable

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Remarks

The ScrollableControl.DockPaddingEdges class creates a margin on a given edge or all edges of a docked control. You can set the width of this margin for each individual edge by setting the following properties: Bottom, Top, Left, Right. Alternatively, you can set all the edges to the same width simultaneously by setting the All property. If the size of the control is too large for its container, the control will be resized to fit in the container, minus the specified margin width.

Example

[Visual Basic, C#, C++] The following example uses the derived class, Panel. The example docks a button in a panel control and cycles through the ScrollableControl.DockPaddingEdges properties, setting each individually on the click of the button. This code assumes a Panel control and a Button have been instantiated on a form, and a class-level member variable named myCounter has been declared as a 32-bit signed integer. This code should be called on the Click event of the button.

[Visual Basic] 
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


[C#] 
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;
 }
 

[C++] 
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 = S"Start";
          break;
       case 1:
          panel1->DockPadding->Top = 10;
          button1->Text = S"Top";
          break;
       case 2:
          panel1->DockPadding->Bottom = 10;
          button1->Text = S"Bottom";
          break;
       case 3:
          panel1->DockPadding->Left = 10;
          button1->Text = S"Left";
          break;
       case 4:
          panel1->DockPadding->Right = 10;
          button1->Text = S"Right";
          break;
       case 5:
          panel1->DockPadding->All = 20;
          button1->Text = S"All";
          break;
    }

    myCounter++;
 }
 

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Windows.Forms

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System.Windows.Forms (in System.Windows.Forms.dll)

See Also

ScrollableControl.DockPaddingEdges Members | System.Windows.Forms Namespace | ScrollableControl

Show:
© 2014 Microsoft