RightToLeftLayout in Panel

前端 未结 3 883
星月不相逢
星月不相逢 2021-01-13 16:11

I have a windows project (C#) which we are going to use for Arabia. As we know the country following Right to Left mechanism. How can i move my all controls position in pane

相关标签:
3条回答
  • 2021-01-13 16:26

    You can do two of the things :

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

    Secondly, Set the HTML dir attribute for the element of each page to"rtl"

    0 讨论(0)
  • 2021-01-13 16:38

    Facts about RightToLeftLayout:

    • It has effect if RightToLeft is set to Yes, only.
    • RightToLeftLayout is a Boolean property and the values are true or false RightToLeftLayout property is not inherited by its child controls.
    • Unlike the RightToLeft property you need to individually set the RightToLeftLayout to each individual control that supports this property.
    • RightToLeftLayout would change the origin of its control and mirror the coordinates. So the origin is at the top-right instead of the top-left of the control. The coordinates would then increase to the left, instead of the right.

    so according to second point you need to set it to all individual child elements

    0 讨论(0)
  • 2021-01-13 16:40

    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 the result like this

    MyRightToLeftLayout = false

    enter image description here

    MyRightToLeftLayout = true

    enter image description here

    0 讨论(0)
提交回复
热议问题