![]() |
Platforms, Frameworks & Libraries »
.NET Framework »
General
Intermediate
FlowLayoutPanel & TableLayoutPanel controls (Visual Studio 2005)By zubinrajVisual Studio 2005 introduces the concept of Layout designing. Two new controls have been added to support this, the FlowLayoutPanel and TableLayoutPanel. This article describes these two new cool features of the new version of the Visual Studio .Net 2005. |
Windows, .NET 2.0VS2005, Dev
|
||||||||
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
There are two interesting components which I noticed in the Windows Forms Toolbox (Visual Studio 2005), which I would like to point out here.
This is apart from the regular 'Panel' control that is included with the previous versions also.

Both of these controls give tremendous control and ease in placing the controls properly and in an orderly fashion on the form.
In the FlowLayoutPanel, whatever controls that you place in the panel, will rearrange itself to right of the previous control, in a flowing model. If the right side of the previous control does not have enough space, it would wrap itself to the next available space at the bottom.
I found this to be very useful while placing many triplets of label->textbox->button controls one below the other and close to each other.
See a screehshot to get a feel of it in action.

You can also decide on the direction in which the controls will flow. For this you have to set the property 'FlowDirection'.
It takes 4 enum values viz.
1. LeftToRight
2. TopDown
3. RightToLeft
4. BottomUp
The automatic wrapping functionality as I explained earlier also can be set by a property called 'WrapContents'. This is boolean field. Default is set to true.
In TableLayoutPanel, the arrangement is in a tabular format as the name itself suggests. When you add a control to a cell of the table, it would reposition itself to the center of the cell. One cell of the table will take only one control. You can add as many rows/columns to the layout.
This is extremely useful while placing multitudes of controls on a form in a correct and orderly fashion. This avoids the main headache while designing a form when it comes to inserting some controls in between the existing controls and you have to sit and re-align all the remaining controls that got affected.

You can manually set the columns and rows the panel should hold by setting the 'ColumnCount' and 'RowCount' properties respectively.
The context menu also supports adding and removing columns and rows.
The Layout feature in the latest Visual Studio 2005 is an excellent addition which gives very good control on how the controls are placed on the form and Microsoft has done a tremendous job in bringing it to the design time.
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 22 Nov 2004 Editor: |
Copyright 2004 by zubinraj Everything else Copyright © CodeProject, 1999-2009 Web13 | Advertise on the Code Project |