2012-03-22 18 views
2

我有一個自定義嚮導控件,我正在修改一個標題和一個子標題。如何在控件中保存和本地化字符串?這裏是字幕屬性:如何在WinForms的自定義控件中本地化字符串?

[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); 
     } 
    } 
} 
+0

當你添加本地化的文件資源沒有做呢? – gbianchi 2012-03-22 17:27:19

+0

它不是我自己的字符串屬性。儘管放在嚮導頁面上的控件是自動本地化的。 – 2012-03-23 00:38:09

回答

3

只需添加本地化屬性

[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); 
     } 
    } 
} 
相關問題