Windows Forms and Controls with Right to Left Layout






4.33/5 (15 votes)
Sep 27, 2003
4 min read

148462

6644
You can get right to left Forms and Controls with mirroring property, which Right to Left Common property can't do.
RightToLeft Property
The base Control
class (from which Form
s 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.
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 |
ErrorProvider |
Not supported | 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 |
ImageList |
Not required | No |
Label |
Displayed right-aligned | No |
LinkLabel |
Displayed 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 |
NotifyIcon |
Not supported | 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 |
PictureBox |
Not supported | No |
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 affected by this property | No |
PrintPreviewDialog |
Text displayed in a Form 's title bar is right-aligned |
No |
ProgressBar |
Not affected 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 |
Splitter |
Not supported | 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 |
Timer |
Not required | 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 |
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 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 Windows 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. You can create mirrored versions of the following controls:
ListView |
Panel |
StatusBar |
TabControl |
TabPage |
ToolBar |
Treeview |
Some controls are sealed, so you cannot derive a new control from them. These include the ImageList
and ProgressBar
controls.
But there is a non-like thing. When you design a Form
and put some some controls on it, the appearance during runtime will be mirrored. The control that you put it at the right of the form will be shown at the left.
History
- 14 Nov 2003 - udpated downloads