Walkthrough: Arranging Controls on Windows Forms Using 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.

 

posted @ 2016-10-18 10:03  ChuckLu  阅读(227)  评论(0编辑  收藏  举报