Change spacing of snaplines in Visual Studio

后端 未结 5 1046
暗喜
暗喜 2020-12-11 16:22

Is it possible to change the amount of space snaplines put between controls in a WinForms project in Visual Studio?

For example, when I slide a textbox up to another

相关标签:
5条回答
  • 2020-12-11 16:34

    You can press and hold the Alt key when dragging controls and release the key after the control is placed in the desired point, so that it does not snap anywhere by default.

    0 讨论(0)
  • 2020-12-11 16:41

    Note that snaplines are used both for spacing (blue lines) and for alignment (pink lines).

    Yes, you can control the amount of space the snaplines suggest, but you do this by altering the Margin and Padding properties of the controls.

    If you slide one control toward another, the length of the snapline is the sum of the Margin of the two controls.

    If you slide a control toward the border of its containing control, the length of the snapline is the sum of the Margin of the control and the Padding of the containing control.

    This is discussed here.

    Edit: There is a special case when the Form is the parent container and the Form's padding is 0,0,0,0.

    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.

    0 讨论(0)
  • 2020-12-11 16:49

    Obviously there is no option setting. You can however achieve your goal with these two meassures: First: Move the control after the drop with the arrow keys. Second: You could place helper buttons at the left right top or bottom side on your container. Snapline will use these as a reference and if they are spaced 4 pixel your new controls will also be 4 pixel appart. You could also press control with an arrow key to move to the next suggested snapline position. Spacing of down to 1 pixel is possible with this. Finally delete your helper buttons.

    Hope it helps.

    0 讨论(0)
  • 2020-12-11 16:50

    There are no snaplines that help you set the spacing between controls, they assist in aligning control edges and text. Instead, the designer pays attention to the Margin property of the control. The default for a Button is (3, 3, 3, 3), it will snap in place creating a 3 pixel gap from the adjacent control.

    Best to try it yourself. Drop a label and a button, change the button's Margin to (3, 10, 3, 3) and move the Button below label up and down. You'll see it now snaps in place creating a 10 pixel gap.

    0 讨论(0)
  • 2020-12-11 16:51

    There is a setting to control the grid spacing under tools -> options -> Windows Forms Designer.

    0 讨论(0)
提交回复
热议问题