RightToLeftLayout in Panel

前端 未结 3 886
星月不相逢
星月不相逢 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: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

提交回复
热议问题