Click here to Skip to main content
Licence 
First Posted 26 Sep 2003
Views 91,881
Bookmarked 33 times

Windows Forms and Controls with Right to Left Layout

By | 14 Nov 2003 | Article
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 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.

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

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

A.Said



Turkey Turkey

Member

BS(Electronics Engineer)

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 1 PinmemberMohammad Rastkar1:12 28 Jul '10  
GeneralMy vote of 1 PinmemberMichael Coyle8:42 30 Mar '10  
GeneralRe: My vote of 1 Pinmemberoeatek4:36 8 Sep '10  
GeneralMy vote of 1 PinmemberMohammad Rastkar6:33 17 Mar '10  
GeneralForm Caption Mirrored when it shouldn't be PinmemberJohnGalt173:49 22 Sep '08  
GeneralHello PinmemberHarold Dunn4:33 16 Sep '08  
GeneralEbrahim Nasr Pinmemberebrahimbaba3:11 30 Mar '07  
QuestionToolbar RTL Pinmembernighelfs4:55 18 Sep '06  
Generalrighttoleft in listbox doesnt work!!!! [modified] Pinmembernafiseh_salmani20:14 13 Aug '06  
GeneralHelp for RTL Tab Pages Pinmembersalianrakesh20:41 24 Feb '06  
Generalgarbage during mouseover in right to left layout Pinmemberaudille22:18 8 Apr '05  
Hi everyone...
Does anyone know why some garbage appears whenever I hover over a link in a right to left layout (for Hebrew/Arabic OSes)?
I have already added window styles WS_EX_NOINHERITLAYOUT and WS_EX_LAYOUT_RTL to my resource files.
Do I need to do some code fixing? The controls are owner-drawn...
I would gladly appreciate any help.
Thanks very much!Smile | :)
GeneralRe: garbage during mouseover in right to left layout PinmemberAverk0:04 11 Dec '05  
GeneralMirror Progressbar in RTL Pinsussdeepapai17:37 28 Mar '05  
GeneralMain Menu PinmemberPeer Adi21:46 15 Nov '04  
GeneralRe: Main Menu Pinmembermshoukry_alkhwarazmi22:43 29 Oct '05  
GeneralTree View PinmemberFakher Halim13:56 10 Aug '04  
GeneralRTL is not perfect ... Pinsussmorali2k1:44 22 May '04  
GeneralListView RTL Pinmemberfabis0:57 10 Mar '04  
GeneralRe: ListView RTL PinsussAnonymous5:51 20 Mar '04  
GeneralMissing Files! Pinmembertim_mcgwyn6:27 27 Sep '03  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120528.1 | Last Updated 15 Nov 2003
Article Copyright 2003 by A.Said
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid