Bi-Directional Support for Windows Forms Applications

You can use Visual Studio to create Windows-based applications that support bi-directional (right-to-left) 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 Control namespace.

Culture Support

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 more information, see Culture-Specific Classes for Global Windows Forms and Web Forms and Culture-Specific Classes for Global Windows Forms and Web Forms and Culture-Specific Classes for Global Windows Forms and Web Forms.

RightToLeft and RightToLeftLayout Properties

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 more information, see How to: Display Right-to-Left Text in Windows Forms for Globalization and How to: Display Right-to-Left Text in Windows Forms for Globalization and How to: Display Right-to-Left Text in Windows Forms for Globalization and How to: Display 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 the property 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. Other controls require that the RightToLeftLayout property be applied to mirror its layout from right to left. The following table provides details on how the RightToLeft and RightToLeftLayout properties affect individual Windows Forms controls.

Control/Component

Effect of RightToLeft property

Effect of RightToLeftLayout property

Requires mirroring?

Button

Sets the RTL reading order. Reverses TextAlign, ImageAlign, and TextImageRelation

No effect

No

CheckBox

The check box is displayed on the right side of the text

No effect

No

CheckedListBox

All the check boxes are displayed on the right side of the text

No effect

No

ColorDialog

Not affected; depends on the language of the operating system

No effect

No

ComboBox

Items in combo box control are right-aligned

No effect

No

ContextMenu

Appears right-aligned with RTL reading order

No effect

No

DataGrid

Appears right-aligned with RTL reading order

No effect

No

DataGridView

Affects both RTL reading order and control layout

No effect

No

DateTimePicker

Not affected; depends on the language of the operating system

Mirrors the control

Yes

DomainUpDown

Left-aligns the up and down buttons

No effect

No

ErrorProvider

Not supported

No effect

No

FontDialog

Depends on the language of the operating system

No effect

No

Form

Sets RTL reading order, and reverses scrollbars

Mirrors the form

Yes

GroupBox

The caption is displayed right aligned. Child controls may inherit this property.

Use a TableLayoutPanel within the control for right-to-left mirroring support

No

HScrollBar

Starts with the scroll box (thumb) right-aligned

No effect

No

ImageList

Not required

No effect

No

Label

Displayed right-aligned. Reverses TextAlign and ImageAlign

No effect

No

LinkLabel

Displayed right-aligned. Reverses TextAlign and ImageAlign

No effect

No

ListBox

Items are right-aligned

No effect

No

ListView

Sets the reading order to RTL; elements stay left-aligned

Mirrors the control

Yes

MainMenu

Displayed right-aligned with RTL reading order at run time (not at design time)

No effect

No

MaskedTextBox

Displays text from right to left.

No effect

No

MonthCalendar

Not affected; depends on the language of the operating system

Mirrors the control

Yes

NotifyIcon

Not supported

Not supported

No

NumericUpDown

Up and down buttons are left-aligned

No effect

No

OpenFileDialog

Not affected; depends on the language of the operating system

No effect

No

PageSetupDialog

Not affected; depends on the language of the operating system

No effect

No

Panel

Child controls may inherit this property

Use TableLayoutPanel within the control for right to left support

Yes

PictureBox

Not supported

No effect

No

PrintDialog

Not affected; depends on the language of the operating system

No effect

No

PrintDocument

The vertical scroll bar become left-aligned and the horizontal scroll bar starts from the left

No effect

No

PrintPreviewDialog

Not supported

Not supported

No

ProgressBar

Not affect by this property

Mirrors the control

Yes

RadioButton

The radio button is displayed on the right side of the text

No effect

No

RichTextBox

Control elements that include text are displayed from right to left with RTL reading order

No effect

No

SaveFileDialog

Not affected; depends on the language of the operating system

No effect

No

SplitContainer

Panel layout is reversed; vertical scrollbar appears on the left; horizontal scrollbar starts from the right

Use a TableLayoutPanel to mirror order of child controls

No

Splitter

Not supported

No effect

No

StatusBar

Not supported; use StatusStrip instead

No effect; use StatusStrip instead

No

TabControl

Not affected by this property

Mirrors the control

Yes

TextBox

Displays text from right to left with RTL reading order

No effect

No

Timer

Not required

Not required

No

ToolBar

Not affected by this property; use ToolStrip instead

No effect; use ToolStrip instead

Yes

ToolTip

Sets the RTL reading order

No effect

No

TrackBar

The scroll or track starts from the right; when Orientation is vertical, ticks occur from the right

No effect

No

TreeView

Sets the RTL reading order only

Mirrors the control

Yes

UserControl

Vertical scrollbar appears on the left; horizontal scrollbar has thumb on the right

No direct support; use a TableLayoutPanel

No

VScrollBar

Displayed on the left side instead of right side of scrollable controls

No effect

No

Encoding

Windows Forms support Unicode, so you can include any character set when you create your bi-directional applications. However, not all Windows Forms controls support Unicode on all platforms. For more information, see Encoding and Windows Forms Globalization.

GDI+

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 correctly 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 the reading order when the message boxes are displayed. For more information, see How to: Create Message Boxes for Bi-Directional Windows Forms.

RightToLeft, Scrollbars, and ScrollableControl

There is currently a limitation in Windows Forms that prevents all classes derived from ScrollableControl from acting properly when both RightToLeft is enabled and AutoScroll is set to Yes. For example, let's say that you place a control such as Panel—or a container class derived from Panel (such as FlowLayoutPanel or TableLayoutPanel)—on your form. If you set AutoScroll on the container to Yes and then set the Anchor property on one or more of the controls inside of the container to Right, then no scrollbar ever appears. The class derived from ScrollableControl acts as if AutoScroll were set to No.

Currently, the only workaround is to nest the ScrollableControl inside another ScrollableControl. For instance, if you need TableLayoutPanel to work in this situation, you can place it inside of a Panel control and set AutoScroll on the Panel to Yes.

Mirroring

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 this setting does not reverse the layout to be right-to-left— that is, it does not cause mirroring. For example, setting this property 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 can mirror these controls by settings the RightToLeftLayout property.

You can create mirrored versions of the following controls:

Some controls are sealed. Therefore, you cannot derive a new control from them. These include the ImageList and ProgressBar controls.

See Also

Concepts

Bidirectional Support for ASP.NET Web Applications

Other Resources

Globalizing Windows Forms