I am using PropertyEditor in .NET 3.5 application to allow users edit settings contained in some serialized class. This application开发者_开发问答 requires localization to support multiple languages. Localized strings implemented using standard .NET Resources.
PropertyEditor requires category, display name and description to be set via attributes. Example below:
[CategoryAttribute("Some category"),
DisplayNameAttribute("Some name"),
DescriptionAttribute("Some description"),
EditorAttribute(typeof(SomeEditor), typeof(System.Drawing.Design.UITypeEditor))]
public SomeType SomeValue {get; set;}
But compiler does not allow me to use resource string in attribute value, changing first line like this:
[CategoryAttribute(Resources.labels.SomeCategory),
Produces error: "The expression being assigned to 'App.Settings.SomeCategory' must be constant."
Can anyone help me how to properly localize property editor in WinForms?
I came across the same problem some month ago. I found no easier/other solution than this article or its follow-up.
I'm not sure if I like that way, but I don't know about any alternative.
精彩评论