Margin and Padding in Windows Forms Controls

https://msdn.microsoft.com/en-us/library/ms229627.aspx

Margin and Padding

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.

Margin

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

Padding

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.

Margin and Padding in Windows Forms Controls

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

Margin and Dock

Margin是控件和父容器的距离;Padding是控件作为父容器的时候,和内部其他控件的距离。

实际使用的时候,默认的边界距离【snapline出现的时候】。是控件的margin和父容器的padding的距离之和。

https://msdn.microsoft.com/en-us/library/system.windows.forms.control.margin(v=vs.110).aspx

Setting the Margin property on a docked control has no effect on the distance of the control from the the edges of its container.

关于Margin属性,在控件使用Dock模式的时候,非DockStyle.None的时候,Margin属性不生效。【可以通过父容器的Padding来控制边界】

Margin属性不生效的方式和DockStyle类型有关,DockStyle.Top和Margin.Top对应,设置DockStyle.Top的时候Margin.Top失效。其他的还保持有效

上一篇:pandas.DataFrame排除特定行


下一篇:spark是怎么从RDD升级到DataFrame的?