我在.NET 3.5应用程序中使用PropertyEditor,以允许用户编辑某些序列化类中包含的设置。此应用程序需要本地化才能支持多种语言。使用标准.NET资源实现的本地化字符串。
PropertyEditor需要通过属性设置类别、显示名称和描述。示例如下:
[CategoryAttribute("Some category"),
DisplayNameAttribute("Some name"),
DescriptionAttribute("Some description"),
EditorAttribute(typeof(SomeEditor), typeof(System.Drawing.Design.UITypeEditor))]
public SomeType SomeValue {get; set;}但是编译器不允许我在属性值中使用资源字符串,将第一行改为这样:
[CategoryAttribute(Resources.labels.SomeCategory),产生错误:“赋值给'App.Settings.SomeCategory‘的表达式必须是常量。”
有人能帮我在WinForms中正确本地化属性编辑器吗?
发布于 2010-02-02 20:33:57
几个月前我遇到了同样的问题。我发现没有比this article或its follow-up更简单的解决方案了。
我不确定我是否喜欢这种方式,但我不知道是否有其他选择。
https://stackoverflow.com/questions/2182754
复制相似问题