【问题标题】:Localization issues PropertyEditor本地化问题 PropertyEditor
【发布时间】: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


    【解决方案1】:

    一个月前我遇到了同样的问题。我发现没有比this articleits follow-up 更简单/其他的解决方案了。

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

    【讨论】:

    • 我在运行时面临类别属性全球化问题。文章作者指出“他希望在.net framework 1.1 中解决这个问题”。它是 .net 4.5,此后没有任何变化。
    猜你喜欢
    • 2013-09-14
    • 2010-12-16
    • 2012-03-26
    • 1970-01-01
    • 2011-02-18
    • 2011-07-11
    • 2011-02-23
    • 1970-01-01
    相关资源
    最近更新 更多