Export (0) Print
Expand All

ScrollableControl.DockPadding Property

Gets the dock padding settings for all edges of the control.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

'Declaration
Public ReadOnly Property DockPadding As DockPaddingEdges
'Usage
Dim instance As ScrollableControl
Dim value As DockPaddingEdges

value = instance.DockPadding

/** @property */
public DockPaddingEdges get_DockPadding ()

public function get DockPadding () : DockPaddingEdges

Property Value

A ScrollableControl.DockPaddingEdges that represents the padding for all the edges of a docked control.

This property controls the border inside of this control for docked components.

The following code 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. The example requires that you have created an instance of a Panel control and a Button on a form, and you have declared a class level member variable named myCounter as a 32-bit signed integer. You should call this code on the Click event of the button.

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.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

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft