Walkthrough: Arranging Controls on Windows Forms Using Snaplines

本文介绍了如何利用Snaplines在Windows Forms中精确地对齐和布局控件。Snaplines是一种直观的方法,当移动控件接近其他控件时,会显示推荐的位置。文章详细解释了Snaplines的工作原理,并通过实例展示了如何将控件对齐到窗体和容器的边界。

https://msdn.microsoft.com/en-us/library/t5b5kc41(v=vs.110).aspx

Spacing and Aligning Controls Using Snaplines

Snaplines give you an accurate and intuitive way to align controls on your form.

They appear when you are moving a selected control or controls near a position that would align with another control or set of controls.

Your selection will "snap" to the suggested position as you move it past the other controls.

To arrange controls using snaplines

1.Drag a Button control from the Toolbox onto your form.
2.Move the Button control to the lower-right corner of the form. Note the snaplines that appear as the Button control approaches the bottom and right borders of the form. These snaplines display the recommended distance between the borders of the control and the form.
3.Move the Button control around the borders of the form and note where the snaplines appear. When you are finished, move the Button control near the center of the form.

snapline在你拖动到form边界的时候,会出现。

 

Aligning to Form and Container Margins

Snaplines help you to align your controls to form and container margins in a consistent manner.

 To align controls to form and container margins

 1.Select one of the  Button controls and move it close to the right border of the form until a snapline appears.
The snapline's distance from the right border is the sum of the control's  Margin property and the form's  Padding property values.
snapline到右边界的距离,是控件margin属性以及formpadding属性的值的和。
 
Note:
If the form's  Padding property is set to 0,0,0,0, the Windows Forms Designer gives the form a shadowed  Padding value of 9,9,9,9. To override this behavior, assign a value other than 0,0,0,0.

 

1.Change the value of the Button control's Margin property by expanding the Margin entry in the Properties window and setting the Allproperty to 0.

For details, see Walkthrough: Laying Out Windows Forms Controls with Padding, Margins, and the AutoSize Property.

2.Move the Button control close to the right border of the form until a snapline appears. This distance is now given by the value of the form's Padding property.

 

3.Drag a GroupBox control from the Toolbox onto your form.

4.Change the value of the GroupBox control's Padding property by expanding the Padding entry in the Properties window and setting the Allproperty to 10.

5.Drag a Button control from the Toolbox into the GroupBox control.

6.Move the Button control close to the right border of the GroupBox control until a snapline appears. Move the Button control within theGroupBox control and note where the snaplines appear.

 

转载于:https://www.cnblogs.com/chucklu/p/5972227.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值