Martin Fejes
Martin Fejes

Reputation: 677

Visual C# - how to align items in winforms?

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?

Upvotes: 4

Views: 6361

Answers (2)

Tarec
Tarec

Reputation: 3255

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..

Upvotes: 3

ReeCube
ReeCube

Reputation: 2607

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

Upvotes: 1

Related Questions