tags:

views:

650

answers:

6

Instead of arranging controls on a winform form by specifying pixel locations, I'd like to lay it out similar to the way you'd layout a form in html. This would make it scale better (for larger fonts etc).

Does anyone know of a layout library that allows you to define the form in xml and lay it out similar to html?

+3  A: 

Have you checked out the TableLayoutPanel and FlowLayoutPanel in the .NET framework? It might be what you are looking for.

Patrik
+2  A: 

Not sure there is anything perfect for this.

MyXAML was kicking about a few years ago that enabled you to add forms in XML as opposed to embedding them into the binary. Not sure if that project is dead or not.

WinForm does have the flow layout control already

However if you want to do this kind of thing properly I think the only answer is to move to WPF.

Quibblesome
A: 

You may also want to consider using Windows Presentation Foundation (WPF) instead of WinForms - WPF has an XML declarative markup language (XAML) that works well for defining scalable UI.

Simon Steele
+2  A: 

Yeah, it's called WPF :)

Seriously, there are some newer panel types in WinForms 2.0 that will let you place controls without setting Location and Size. They are FlowLayoutPanel and TableLayoutPanel.

You should also look into the AutoSize property. It takes care of sizing when the value of the label, say, changes. Also, don't forget about Docking and Anchoring.

Once you master those concepts, writing a little parser that converts from XML to controls shouldn't be that hard if you feel you really need it.

ageektrapped
A: 

I've already got something like MyXAML - my screens are loaded from xml files already. It suffers the same problem as MyXAML which is that you still have to position the controls with pixel positions whereas I want something like html with the automatic flow and tables and such.

I think TableLayoutPanel might be what I'm looking for.

dan gibson
A: 

The only one I know of is a 3rd party from DevExpress called the LayoutControl..

chrishawn