As I said in the title center horizontally and verticaly buttons aligns my controls in Visual Studio C# according to form size which I randomly put to see my for clearly ( 751; 469 ) to be exact, it centers the controlls according to that size but my form starts as maximized window as it should be. How can I align the controls as the window maximized?
Most simple will be to change the anchoring, as mentioned here Centering controls within a form in .NET (Winforms)?
Or
we can also explore TableLayoutPanel
. This is what comes to my mind -
On the main form Control Add a TableLayoutPanel
with 3 Column
and 3 Row
, To make a 3x3 matrix. Set its Dock
style to Fill
you can configure the width of column & rows in %age so the middle cell of this matrix takes the maximum area, something like this
Dock
style set to Fill
), & then I'll add controls to this panel. The anchoring of these controls is set to none.this is how it looks at design time
And it scales pretty well when you maximize the window at runtime, like this
Hope adding table makes it an easy design. Incase of any issues please write me a comment.