|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
Best Practices for the TableLayoutPanel Control
The TableLayoutPanel control provides powerful layout features that you should consider carefully before using on your Windows Forms.
The following recommendations will help you use the TableLayoutPanel control to its best advantage.
Use the TableLayoutPanel control sparingly. You should not use it in all situations that require a resizable layout. The following list describes layouts that benefit most from the use of the TableLayoutPanel control:
Layouts in which there are multiple parts of the form that resize proportionally to each other.
Layouts that will be modified or generated dynamically at run time, such as data entry forms that have user-customizable fields added or subtracted based on preferences.
Layouts that should remain at an overall fixed size. For example, you may have a dialog box that should remain smaller than 800 x 600, but you need to support localized strings.
The following list describes layouts that do not benefit greatly from using the TableLayoutPanel control:
Simple data entry forms with a single column of labels and a single column of text-entry areas.
Forms with a single large display area that should fill all the available space when a resize occurs. An example of this is a form that displays a single PropertyGrid control. In this case, use anchoring, because nothing else should expand when the form is resized.
Choose carefully which controls need to be in a TableLayoutPanel control. If you have room for your text to grow by 30% using anchoring, consider using the Anchor property only. If you can estimate the space required by your layout, use of Dock and Anchor is easier than estimating the details of remaining space and AutoSize behavior.
In general, when designing your layout with the TableLayoutPanel control, keep the design as simple as possible.
Use the Document Outline Window
The Document Outline window gives you a tree view of your layout, which you can use to manipulate the z-order and parent-child relationships of your controls. From the View menu, select Other Windows, then select Document Outline.