RightToLeftLayout in the panel

I have a windows project (C #) that we are going to use for Arabia. As we know, this country is following the Right to Left mechanism. How can I move all the controls in the panel in RTL format (from right to left). I set the "RightToLeft" and "RightToLeftLayout" properties to true, but it moves the controls inside the form, not the panel. See Example

enter image description here

I applied the specified properties when the controls are moved, which are just in the form, but control the inner panel, remain as they are.

+4
source share
3 answers

you can use this control :)

class MyPanel:Panel { private bool myRightToLeftLayout=false; public bool MyRightToLeftLayout { get { return myRightToLeftLayout; } set { if (value != myRightToLeftLayout) { foreach (Control item in base.Controls) { try { item.RightToLeft = value==true?RightToLeft.No:RightToLeft.Yes; item.Location = new System.Drawing.Point(base.Size.Width - item.Size.Width - item.Location.X, item.Location.Y); } catch { } } myRightToLeftLayout = value; } } } } 

and a result like this

MyRightToLeftLayout = false

enter image description here

MyRightToLeftLayout = true

enter image description here

+3
source

Facts about RightToLeftLayout:

  • This is valid if RightToLeft is set to Yes only.
  • RightToLeftLayout is a Boolean property, and values ​​are true or false The RightToLeftLayout property is not inherited by its child controls.
  • Unlike the RightToLeft property, you need to individually set the RightToLeftLayout for each individual control that supports this property.
  • RightToLeftLayout will change the start of its control and display the coordinates. Thus, the origin is in the upper right corner, and not in the upper left of the control. Then the coordinates will increase to the left, and not to the right.

therefore, according to the second point, you need to set it for all individual child elements

0
source

You can do two things:

First, in the Web.config file of the web application, set the culture attribute of the <globalisation> element to "ar-SA"

Second, set the HTML dir attribute for each page element to "rtl"

-one
source

All Articles