How to set controls on center of the winform?

Place the control on the center and set Anchor property to None.


Center aligning a label can be done in Design View. Navigate to 'Properties' there is a setting called 'Autosize' that you have to turn off (set it to false). This allows you to set the width of the label to the width of the page.

Then scroll down in 'Properties' to the setting called 'TextAlign' and set it to 'MiddleCenter'. That should fix the problem.


you can do it Using the layout control

  1. Add TableLayout Control, Set it’s Dock property to Fill.
  2. Add 1 Row with Size Type style Percent 100%
  3. Add 3 Columns Column1(Size Type – Percent(100%)), Column2(Size Type – Absolute(200px)), Column3(Size Type – Percent(100%)).
  4. Now Add Panel Control to Column2 and Set it’s Dock property to Fill
  5. Add Buttons to this control and set their Size as you want and Set Their Anchor Property to AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top

Reference

Tags:

C#

.Net

Winforms