RightToLeftLayout在面板 [英] RightToLeftLayout in Panel
问题描述
我有一个Windows项目(C#),我们将要使用的沙特阿拉伯。我们知道全国下面从右到左的机制。我怎样才能将我的所有控件的位置在面板RTL(从右到左)格式。我已经设置属性从右至左和RightToLeftLayout为真,但它的动作形式不仅没有面板的内部控制。参见示例
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 panel in RTL(Right to left) format. I have set properties 'RightToLeft' and 'RightToLeftLayout' to true but it moves controls inside the form only not panel. See the example
我的属性加说,当控制移动这只是形式,但里面的面板控制,保持原样。
I had applied said properties when controls moved which are simply on the form, but controls inside panel, remain as is.
推荐答案
您可以使用此控件:)
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;
}
}
}
}
和结果像这样
MyRightToLeftLayout = FALSE
MyRightToLeftLayout = TRUE
这篇关于RightToLeftLayout在面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!