4

This is my first C# program so please, forgive me.

I'm using winforms (WPF seemed more alien) and I'd like to center (or align somehow) the items on a form, but I don't know how.

I tried the Format menu, but everything is greyed out and, in code view, nothing like HorizontalAlign property was in the suggestions.

What am I doing wrong?

Martin Fejes
  • 677
  • 12
  • 20
  • Visual Studio should allow aligning from top menu. Make sure you are not running application when aligning. Also select multiple items with a control button pressed down and then align controls. – Panu Oksala Feb 28 '14 at 10:27
  • possible duplicate of [C#: Centering controls within a form in .NET (Winforms)?](http://stackoverflow.com/questions/491399/c-centering-controls-within-a-form-in-net-winforms) – Crypth Feb 28 '14 at 10:33

2 Answers2

3

Set anchor of an item to left and right to keep it centered horizontally and top+bottom to center the item vertically. However if you have few items you want to center that's not doable really, unless you'll put them in a grouping control like Panel for example.

Edit: I assumed we're talking about keeping items centered at runtime, because for adjusting a control to the center position there's a button on your toolbar, you know..

Tarec
  • 3,268
  • 4
  • 30
  • 47
1

There should be an Dock attribute, is this what you were looking for?

ReeCube
  • 2,545
  • 17
  • 23