我在 .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 中正确本地化属性编辑器?

有帮助吗?

解决方案

一个月前我遇到了同样的问题。我发现没有比这更简单/其他的解决方案了 本文 或者 它的后续.

我不确定我是否喜欢这种方式,但我不知道还有什么其他选择。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top