Edit

Share via


ScrollableControl.DockPaddingEdges Class

Definition

Determines the border padding for docked controls.

C#
[System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.ScrollableControl+DockPaddingEdgesConverter))]
public class ScrollableControl.DockPaddingEdges : ICloneable
Inheritance
ScrollableControl.DockPaddingEdges
Attributes
Implements

Examples

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.

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

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.

Properties

All

Gets or sets the padding width for all edges of a docked control.

Bottom

Gets or sets the padding width for the bottom edge of a docked control.

Left

Gets or sets the padding width for the left edge of a docked control.

Right

Gets or sets the padding width for the right edge of a docked control.

Top

Gets or sets the padding width for the top edge of a docked control.

Methods

Equals(Object)

This API supports the product infrastructure and is not intended to be used directly from your code.

Determines whether the specified object is equal to the current ScrollableControl.DockPaddingEdges object.

GetHashCode()

Serves as a hash function for a particular type.

GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns an empty string.

Explicit Interface Implementations

ICloneable.Clone()

Creates a new object that is a copy of the current instance.

Applies to

Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

See also