C# 如何在WinForms中本地化自定义控件中的字符串?
我有一个自定义向导控件,我正在用标题和副标题修改它。如何在控件中保存和本地化字符串?以下是SubTitle属性:C# 如何在WinForms中本地化自定义控件中的字符串?,c#,.net,winforms,C#,.net,Winforms,我有一个自定义向导控件,我正在用标题和副标题修改它。如何在控件中保存和本地化字符串?以下是SubTitle属性: [Category("Appearance"), DefaultValue("Description for the new page."), Description("The subtitle of the page."), Editor(typeof(MultilineStringEditor), typeof(UITypeEditor))] public string Subt
[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);
}
}
}
只需添加本地化属性
[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);
}
}
}
添加资源本地化文件时不是这样吗?对于我拥有的字符串属性,这不是自动的。但是,拖放到向导页面上的控件会自动本地化。