|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. ArchiveDisclaimer|
Bi-directional Support for Windows Applications
You can use Visual Studio to create Windows applications that support bi-directional languages such as Arabic and Hebrew. This includes standard forms, dialog boxes, MDI forms, and all the controls you can work with in these forms — that is, all the objects in the System.Windows.Forms.Control namespace.
Culture and UI culture settings determine how an application works with dates, times, currency, and other information. Support for culture and UI culture is the same for bi-directional languages as it is for any other languages. For details, see Culture-Specific Classes for Global Windows Forms and Web Forms.
The base Control class (from which forms derive) includes a RightToLeft property that you can set to change the reading order of a form and its controls. If you set the form's RightToLeft property, by default controls on the form inherit this setting. However, you can also set the RightToLeft property individually on most controls. For details, see Displaying Right-to-Left Text in Windows Forms for Globalization.
The effect of the RightToLeft property can differ from one control to another. In some controls it only sets the reading order, as in the Button, TreeView and ToolTip controls. In other controls, the RightToLeft property changes both reading order and layout. This includes the RadioButton, ComboBox and CheckBox controls. The following table provides details on how the RightToLeft property affects individual Windows Forms controls.
|Control/Component||Effect of RightToLeft property||Requires mirroring?|
|Button||Sets the RTL reading order||No|
|CheckBox||The check box is displayed on the right side of the text||No|
|CheckedListBox||All the check boxes are displayed on the right side of the text||No|
|ColorDialog||Not affected; depends on the language of the operating system||No|
|ComboBox||Items in combo box control are right-aligned||No|
|ContextMenu||Appears right-aligned with RTL reading order||No|
|DataGrid||Appears right-aligned with RTL reading order||No|
|DateTimePicker||Not affected; depends on the language of the operating system||No|
|DomainUpDown||Left-aligns the up and down buttons||No|
|FontDialog||Depends on the language of the operating system||No|
|GroupBox||The caption is displayed right aligned. Child controls may inherit this property.||No|
|HScrollBar||Starts with the scroll box (thumb) right-aligned||No|
|ListBox||Items are right-aligned||No|
|ListView||Sets the reading order to RTL; elements stay left-aligned||Yes|
|MainMenu||Displayed right-aligned with RTL reading order at run time (not at design time)||No|
|MonthCalendar||Not affected; depends on the language of the operating system||No|
|NumericUpDown||Up and down buttons are left-aligned||No|
|OpenFileDialog||Not affected; depends on the language of the operating system||No|
|PageSetupDialog||Not affected; depends on the language of the operating system||No|
|Panel||Child controls may inherit this property||Yes|
|PrintDialog||Not affected; depends on the language of the operating system||No|
|PrintDocument||The vertical scroll bar become left-aligned and the horizontal scroll bar starts from the left||No|
|PrintPreview||Not affect by this property||No|
|PrintPreviewDialog||Text displayed in a form's title bar is right-aligned||No|
|ProgressBar||Not affect by this property||Yes|
|RadioButton||The radio button is displayed on the right side of the text||No|
|RichTextBox||Control elements that include text are displayed from right to left with RTL reading order||No|
|SaveFileDialog||Not affected; depends on the language of the operating system||No|
|StatusBar||The text in the panels is right-aligned with RTL reading order||Yes|
|TabControl||Not affected by this property||Yes|
|TextBox||Displays text from right to left with RTL reading order||No|
|ToolBar||Not affected by this property||Yes|
|ToolTip||Sets the RTL reading order||No|
|TrackBar||The scroll or track starts from the right||No|
|TreeView||Sets the RTL reading order only||Yes|
|VScrollBar||Displayed on the left side rather than right side of scrollable controls||No|
Windows Forms support Unicode, so you can include any character set when creating them. However, not all Windows Forms controls support Unicode on all platforms. For details, see Encoding and Windows Forms Globalization.
You can use GDI+ to draw text with right-to-left reading order. The DrawString method, which is used to draw text, supports a StringFormat parameter that you can set to the DirectionRightToLeft member of the StringFormatFlags enumeration in order to reverse the point of origin for the text.
Common Dialog Boxes
System tools such as the File Open dialog box are under the control of Windows. They inherit language elements from the operating system. If you are using a version of Windows with the correct language settings, these dialog boxes will work properly with bi-directional languages.
Similarly, message boxes go through the operating system and support bi-directional text. The captions on message box buttons are based on the current language setting. By default, message boxes do not use right-to-left reading order, but you can specify a parameter to change this when displaying the message box. For details, see Creating Message Boxes for Bi-Directional Windows Applications.
Mirroring refers to reversing the layout of UI elements so that they flow from right to left. In a mirrored Windows Form, for example, the Minimize, Maximize, and Close buttons appear left-most on the title bar, not right-most.
Setting a form or control's RightToLeft property to true reverses the reading order of elements on a form, but it does not reverse the layout to be right-to-left — that is, it does not cause mirroring. For example, it does not move the Minimize, Maximize, and Close buttons in the form's title bar to the left side of the form. Similarly, some controls, such as the TreeView control, require mirroring in order to change their display to be appropriate for Arabic or Hebrew.
You cannot directly mirror a form or control. However, you can create mirroring in code. For forms, you can set an extended Window style to cause mirroring. For most controls that require mirroring, you can create a mirrored control by inheriting from the base control and setting the same Windows extended style. For details, see Creating Mirrored Windows Forms and Controls.
You can create mirrored versions of the following controls.
Some controls are sealed, so you cannot derive a new control from them. These include the ImageList and ProgressBar controls.
Creating Mirrored Windows Forms and Controls | Creating Message Boxes for Bi-Directional Windows Applications | Bi-directional Support for Web Applications | Globalizing Windows Forms | Localizing Applications | Visual Studio .NET With Arabic Language Support (this link goes to the Microsoft.com Web site)