由于Empty Name属性,无法本地化ObjectListView OLVColumn

本文关键字:本地化 ObjectListView OLVColumn Empty Name 属性 由于 | 更新日期: 2023-09-27 18:25:35

所以,我正在尝试本地化/翻译现有的应用程序,这段代码在基本表单上运行,一切都按预期运行,直到它运行到BrightIdeasSoftware.ObjectListView(它正确地迭代子项等)。问题是,在ObjectListView上,列应该有一个Name集,但它总是为null。

ComponentResourceManager parentManager = new ComponentResourceManager(this.GetType());
CultureInfo language = new CultureInfo("en");
foreach (Control subControl in this.Controls) {
    parentManager.ApplyResources(subControl, subControl.Name, language);
}

当它运行到ObjectListView:时

ObjectListView localControl = (ObjectListView)subControl;
foreach (OLVColumn column in localControl.Columns)
{
    parentManager.ApplyResources(column, column.Name/*This is the issue*/, language);
}

当我在设计器代码中设置列的名称时,它确实按预期工作,而且在更改后,它确实再次正确地生成了名称代码,但我不能在每次向项目中添加名称属性时,都遍历整个项目,将名称属性添加到所有objectListView中。

我尝试过查找任何包含Name值的属性,但没有找到(它显示在设计器GUI中)。

我试着在OLV支持论坛上搜索解决方案,但找不到,并注意到很多有OLV问题的人在这里得到了一些帮助,所以我想我应该先在这里寻求帮助。

非常感谢您的帮助,提前感谢!

由于Empty Name属性,无法本地化ObjectListView OLVColumn

它没有自动添加"名称"

this.olvColSetPartName.AspectName = "Name";
resources.ApplyResources(this.olvColSetPartName, "olvColSetPartName");

给它一个"名称"

this.olvColSetPartName.Name = "olvColSetPartName";