【发布时间】:2010-02-02 08:42:52
【问题描述】:
我在 .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 中正确本地化属性编辑器?
【问题讨论】:
标签: c# winforms localization propertyeditor