Partager via


Margin and Padding in Windows Forms Controls

Precise placement of controls on your form is a high priority for many applications. The System.Windows.Forms namespace gives you many layout features to accomplish this. Two of the most important are the Margin and Padding properties.

The Margin property defines the space around the control that keeps other controls a specified distance from the control's borders.

The Padding property defines the space in the interior of a control that keeps the control's content (for example, the value of its Text property) a specified distance from the control's borders.

The following illustration shows the Padding and Margin properties on a control.

Padding And Margin for Windows Forms Controls

There is design-time support for this feature in Visual Studio. Walkthrough: Laying Out Windows Forms Controls with Padding, Margins, and the AutoSize Property
Walkthrough: Laying Out Windows Forms Controls with Padding, Margins, and the AutoSize Property
Walkthrough: Laying Out Windows Forms Controls with Padding, Margins, and the AutoSize Property
Walkthrough: Laying Out Windows Forms Controls with Padding, Margins, and the AutoSize Property

See Also

Reference

AutoSize
Margin
Padding
LayoutEngine
TableLayoutPanel
FlowLayoutPanel