space winforms controls
I have a simple winforms app with a column of several buttons. What is the nicest way to enforce that they are equally 开发者_运维问答spaced vertically?
Drag a rectangle around them in the designer so they all get selected. Use Ctrl + Left mouse click to adjust the selection if necessary. In the menu: Format + Vertical Space + Make Equal.
If you want to make the spacing dynamic (ie: it updates when the user changes the size of the window) the best approach would be to create a TableLayoutPanel
with 5 rows (and probably just one column). Set its Dock
property to Fill
, and make sure each row has automatic size.
After that, you place your buttons on the panel, and it will do the positioning for you.
Set the top and bottom margins on each control to the same thing, and then drag them together using snaplines to line them all up.
Change the location parameters in the properties windows to be proportionally aligned.
精彩评论