The Padding structure represents the padding or margin associated with a rectangular UI element such as a control. The padding is the internal space between the body of the UI element and its edge. In contrast, a margin is the distance separating the adjoining edges of two adjacent UI elements. Because of structural similarities, Padding is used to represent both padding and margins.
For a diagram that illustrates the Padding and Margin properties on a control, see Margin and Padding in Windows Forms Controls.
Padding has a different effect on controls that are containers than on controls that are not. For example, in a Panel control, the Padding property defines the spacing between the border of the Panel and its child controls. For a Button control, the Padding property defines the spacing between the border of the Button control and its contained text.
In addition to typical methods and properties, Padding also defines the following type-level members:
-
The Empty field, which represents a predefined Padding with no padding.
-
A set of operators for performing common arithmetic operations for the class, such as adding two Padding objects together. For languages that do not support operator overloading, you can invoke these members by using alternative method syntax.
-
The Horizontal, Vertical, and Size properties, which provide combined values that are convenient for use in custom layout calculations.