自定义控制从右到左布局

时间:2017-04-28 14:14:25

标签: c# winforms

我已下载自定义ListView控件,该控件不包含从右到左布局的属性。 我写了这段代码:

public class CustomListView : SourceListView
{
    const int WS_EX_LAYOUTRTL = 0x400000;
    const int WS_EX_NOINHERITLAYOUT = 0x100000;
    private bool rightToLeftLayout = false;


    public CustomListView() : base()
    {
        //SetStyle(ControlStyles.UserPaint, true);

    }

    [Localizable(true)]
    public bool RightToLeftLayout
    {
        get { return rightToLeftLayout; }
        set
        {
            if (rightToLeftLayout != value)
            {
                rightToLeftLayout = value;
                this.RecreateHandle();
            }
        }
    }
    protected override CreateParams CreateParams
    {
        get
        {
            CreateParams CP;
            CP = base.CreateParams;
            if (this.RightToLeftLayout &&
                this.RightToLeft == System.Windows.Forms.RightToLeft.Yes)
                CP.ExStyle = CP.ExStyle | WS_EX_LAYOUTRTL | WS_EX_NOINHERITLAYOUT;
            return CP;
        }
    }

翻转ListView水平而不是从右到左绘制文字 示例:

我需要做些什么来解决它?

0 个答案:

没有答案