如何在WinForms中自定义控件中本地化字符串?

时间:2012-03-22 16:47:49

标签: c# .net winforms

我有一个自定义向导控件,我正在使用Title和SubTitle进行修改。如何在控件中保存和本地化字符串?这是SubTitle属性:

[Category("Appearance"), DefaultValue("Description for the new page."), Description("The subtitle of the page."), Editor(typeof(MultilineStringEditor), typeof(UITypeEditor))]
public string Subtitle
{
    get { return subtitle; }
    set
    {
        if (subtitle != value)
        {
            Region regionToInvalidate = GetTextRegionToInvalidate();
            subtitle = value;
            regionToInvalidate.Union(GetTextRegionToInvalidate());

            Invalidate(regionToInvalidate);
        }
    }
}

1 个答案:

答案 0 :(得分:3)

只需添加Localizable属性

即可
[Category("Appearance"), DefaultValue("Description for the new page."), Description("The subtitle of the page."), Editor(typeof(MultilineStringEditor), typeof(UITypeEditor))]
[Localizable(true)]
public string Subtitle
{
    get { return subtitle; }
    set
    {
        if (subtitle != value)
        {
            Region regionToInvalidate = GetTextRegionToInvalidate();
            subtitle = value;
            regionToInvalidate.Union(GetTextRegionToInvalidate());

            Invalidate(regionToInvalidate);
        }
    }
}