RE: Programmatically space controls evenly

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi,

To add to Stephany's post, there are no methods that you can use to space
controls evenly. You have to calculate the positions yourself. That being
said, it is fairly simple math, and you can easily recalculate the positions
when the SizeChanged event is triggered to support resizing of the dialog.

--
Happy Coding!
Morten Wennevik [C# MVP]


"proxyuser" wrote:

Let's say you had a dialog where you wanted to display either 2 or 3
buttons, but either way you wanted them spaced evenly across the bottom. In
other words, sometimes there are 2 buttons with the 3rd hidden, but when the
3rd unhides you want the other 2 to shift over. In the Designer, you can
select them and click on Make Horizontal Spacing Equal. Is there a way to
do this programmatically? It seems tedious to have to actually figure out
the pixels to move each button.



.


Quantcast