Walkthrough: Creating a Layout That Adjusts Proportion for Localization
Creating forms that are ready to be localized greatly speeds development for international markets.
This walkthrough illustrates how to create a layout that proportionally adjusts when you translate displayed string values into other languages. This process of translation is called localization. For more information, see Localizing Applications. For information about how to localize a completed Windows Form, see Walkthrough: Localizing Windows Forms
Tasks illustrated in this walkthrough include:
Creating the Project
Preserving Vertical Alignment
Enabling Proportional Resizing
When you are finished, your form will look similar to the following:
For the complete code listing, see How to: Design a Windows Forms Layout that Responds Well to Localization.
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 Working with Settings.
The first step is to create the application project. You will use this project to build the application that shows the data-entry form.
To create the project
Create a Windows Application project called DemoLocalizableForm. For more information, see How to: Create a New Windows Forms Application Project.
To use automatic sizing
Drag a TableLayoutPanel control from the Toolbox onto your form. Set the value of its RowCount property to 1. Set the value of its AutoSize property to true. Size the TableLayoutPanel control to occupy about half of the form.
Drag two more Button controls from the Toolbox into the Panel control. Position them beneath the first Button control. Use snaplines to align them vertically and to space them evenly. For more information, see Walkthrough: Arranging Controls on Windows Forms Using Snaplines.
Select the TableLayoutPanel control and open the Columns and Row Styles dialog box. For more information, see How to: Edit Columns and Rows in a TableLayoutPanel Control.
Change the value of the first Button control's Text property to a long string, for example "This is a long string to demonstrate a localizable form." Note All three Button controls and the TableLayoutPanel cell are resized to fit the new string length.
To enable proportional resizing
Set the value of the second TableLayoutPanel control's AutoSize property to true. Set the value of the ColumnCount property to 3. Set the value of the RowCount property to 1. Set the value of the Anchor property on the TableLayoutPanel control to Right, Bottom.
Open the Columns and Row Styles dialog box.
Change the value of the first Button control's Text property to a long string, for example "This is a long string to demonstrate a localizable form." Note that the Button controls are all resized to fit the new string length. Also note that the TableLayoutPanel control is resized and its cells are proportionally resized.
Now that you can create localizable forms, consider implementing a dynamic layout that proportionally adjusts as the user resizes the form. For more information, see Walkthrough: Creating a Resizable Windows Form for Data Entry.