Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dock, Anchor and Fluid layouts in Windows Forms Applications

So, I've been asked to redesign an old application I wrote a few years ago.

Basically, nothing much needs to be changed, except that the Customer wants it to be more fluid, and that it must be fullscreen (no visible "window") I.e. no Titlebar, just a Borderless fullscreen Window.

What is the best way to make sure everything stays fluid, I mean how can we make sure everything appears where it should, 'cause you know, different resolutions, monitor sizes etc?

This is easy in web pages/css, but this is not something I've done before. Most of the Controls will be created programatically at runtime, based on what action was performed, etc. How would I accomplish such a layout? Basically I want to be able to lay it all out full screen, without knowing how large their monitor is, or what resolution they're using.

like image 238
bendr Avatar asked Jun 24 '11 09:06

bendr


People also ask

What is dock in Windows form?

Remarks. Use the Dock property to define how a control is automatically resized as its parent control is resized. For example, setting Dock to DockStyle. Left causes the control to align itself with the left edges of its parent control and to resize as the parent control is resized.

How is anchoring different from docking?

Anchor refers to the position a control has relative to the edges of the form. A textbox, for example, that is anchored to the left edge of a form will stay in the same position as the form is resized. Docking refers to how much space you want the control to take up on the form.

What are the features of Windows Form application?

The Windows Forms development platform supports a broad set of app development features, including controls, graphics, data binding, and user input. Windows Forms features a drag-and-drop visual designer in Visual Studio to easily create Windows Forms apps.


1 Answers

Your certainly correct in trying to design your form using a fluid layout that responds to the size of the available space and size of the form font. To do that you want to use the following controls and control properties.

1, TableLayoutPanel will split an area into a set of rows and columns and allow you to position your child controls within individual cells of that table layout. This responds to a change in the form width and height.

2, FlowLayoutPanel will position your child controls from left to right and automatically move to a new row when you run out of space. This is great for a fluid design as it will adjust the layout depending on the available space.

3, Control.Anchor property allows a child control to alter position and size based on the size of the form client area. So you make your control always be a fixed offset from the right or bottom edges.

4, Control.Dock property will position a child control against an edge and the opposite size will automatically be defined by the containing form.

like image 67
Phil Wright Avatar answered Nov 15 '22 18:11

Phil Wright