Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

ScrollableControl.DockPaddingEdges Class

Determines the border padding for docked controls.

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

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)
[TypeConverterAttribute(typeof(ScrollableControl..::..DockPaddingEdgesConverter))]
public class DockPaddingEdges : ICloneable

The ScrollableControl.DockPaddingEdges type exposes the following members.

  NameDescription
Public propertyAllGets or sets the padding width for all edges of a docked control.
Public propertyBottomGets or sets the padding width for the bottom edge of a docked control.
Public propertyLeftGets or sets the padding width for the left edge of a docked control.
Public propertyRightGets or sets the padding width for the right edge of a docked control.
Public propertyTopGets or sets the padding width for the top edge of a docked control.
Top
  NameDescription
Public methodEqualsInfrastructure. Determines whether the specified Object is equal to the current Object. (Overrides Object.Equals(Object).)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeInfrastructure. Serves as a hash function for a particular type. (Overrides Object.GetHashCode().)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringInfrastructure. Returns an empty string. (Overrides Object.ToString().)
Top
  NameDescription
Explicit interface implemetationPrivate methodICloneable.CloneCreates a new object that is a copy of the current instance.
Top

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.

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. This code requires that 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.


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


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.