How to: Support Localization on Windows Forms Using AutoSize and the TableLayoutPanel Control
One of the difficulties you may encounter when you localize your application is changes to your layout introduced by text strings of varying lengths. Theproperty and the control can be helpful in creating layouts that can adapt to different text string lengths that you cannot anticipate at design time.
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see.
Enabling a Layout that Adapts to Varying String Sizes
The AutoSize property causes a control to size itself to its content. The TableLayoutPanel control provides a proportional resizing capability that enables controls to retain the same relative size when they are resized to fit their contents.
To enable automatic sizing for localization
Drag a TableLayoutPanel control from the Toolbox onto your form. Set the value of theproperty to 1. Set the value of the AutoSize property to true.
Drag acontrol from the Toolbox into the left cell in the TableLayoutPanel control. Set the value of its AutoSize property to true.
Open the Columns and Row Styles dialog box. For more information, see. Select Column1 and change the value of its property to . Click the OK button to accept your changes.
Set the value of the Button control'sproperty to a long string, for example "This is a long string to demonstrate a localizable form." The Button control and the TableLayoutPanel cell are resized to fit the new string length.
Change the value of the Button control's Text property to a short string. The width of the Button control and the TableLayoutPanel cell are reduced to fit the shorter string.
Move the TableLayoutPanel control so it is flush with the lower-right corner of the form.
Set the value of the form'sproperty to true.
Change the value of the Button control's Text property to a long string, for example "This is a long string to demonstrate a localizable form." If the string is long enough, it causes the TableLayoutPanel control and the form to increase in size.