Dela via


How to: Create Mirrored Windows Forms and Controls

Some language scripts, such as Arabic and Hebrew, are traditionally written and read from right to left, instead of from left to right. Users of right-to-left language scripts not only expect text in their software applications to flow from right to left, they also expect that all of the controls on a form flow from right to left. When you place text and controls on a form in right-to-left order it is called mirroring, because you are creating a mirror image of the more common left-to-right order.

The RightToLeft property on forms and controls determines the reading order of these objects, while the RightToLeftLayout property controls how forms and some container controls render their contained controls. RightToLeftLayout is not defined on every control, however; TabControl, GroupBox, and Panel are a few controls that lack an implementation. For these controls, you must use one of the panel layout controls, such as FlowLayoutPanel or TableLayoutPanel, to achieve true right-to-left rendering of a control's contained controls.

The following procedure demonstrates how to mirror your form to render from right to left, and how to compensate for some of the limitations of RightToLeftLayout support.

For more information about arranging text in right-to-left order, see How to: Display Right-to-Left Text in Windows Forms for Globalization

Note

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 Visual Studio Settings.

To create a mirrored Windows Form or control

  1. Create a new Windows Forms project in Visual Studio. For more information, see How to: Create a Windows Application Project.

  2. In the Property Editor for Form1, set RightToLeft to Yes and RightToLeftLayout to True.

  3. Drag a TabControl from the Toolbox and onto the form.

  4. In the Property Editor for TabControl1, set the Dock property to Full, which is the center square in the property's UI editor.

  5. Set the RightToLeftLayout property of the TabControl to True.

  6. Drag a FlowLayoutPanel control from the Toolbox onto tabPage1. The control will base its default layout order on the RightToLeft property of tabPage1, meaning in this case that it will default to Yes.

  7. Add a Label, TextBox and Button control to the FlowLayoutPanel.

  8. Run the project. You should see the entire form—including the title bar, control boxes, and all contained controls—render from right to left.

See Also

Tasks

How to: Display Right-to-Left Text in Windows Forms for Globalization

Concepts

Bi-Directional Support for Windows Forms Applications

Other Resources

Globalizing and Localizing Applications

Windows Forms Visual Inheritance