自定义属性描述符和扁平化层次结构

发布于 2024-07-17 05:16:39 字数 505 浏览 3 评论 0原文

我有一个自定义属性描述符,用于支持扁平化对象层次结构。

为了实现此目的,我对 PropertyDescriptor 进行了子类化,并将链接列表存储到我想要检索其值的“下一个”(子)属性。

这使我能够以“平面”方式将子属性绑定到网格(导出到 Excel 等)。

例如。 Grid(bound Property, Caption)

Col1:Customer.Name(Customer)
Col2:Customer.Address(Address)
Col3:Customer.OutstandingOrders.Count(Outstanding Orders)

问题是,一旦我添加具有重复名称的列,无论它有一个唯一的标题,它都会检索第一个标题的属性,但仍然将正确的标题放入:

Col4:Customer.Company.Name(Company)

任何想法?

I have a custom property descriptor that I use to support flattening object hierarchies.

To accomplish this I subclassed PropertyDescriptor and I store a linked list to the "next" (child) property that I want to retrieve the value for.

This enables me to bind subproperties to a grid(export to excel, whatever) in a "flat" manner.

eg.
Grid(bound Property, Caption)

Col1:Customer.Name(Customer)
Col2:Customer.Address(Address)
Col3:Customer.OutstandingOrders.Count(Outstanding Orders)

The problem is that once I add in a column with a duplicate name, regardless of the fact it's got a unique caption it will retrieve the property for the 1st one but still put the correct header in:

Col4:Customer.Company.Name(Company)

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回眸一遍 2024-07-24 05:16:39

问题是,一旦我添加具有重复名称的列,无论它是否具有唯一的标题,它都会检索第一个标题的属性,但仍会放入正确的标题。

您能澄清一下这一行吗? 我之前已经这样做过,但我在虚构名称中使用了导航路径 - 即我可能拥有 PropertyDescriptor.Name 报告 Customer_Company_Name 而不是 Name,并使用 .DisplayName 报告更具可读性的内容。

The problem is that once I add in a column with a duplicate name, regardless of the fact it's got a unique caption it will retrieve the property for the 1st one but still put the correct header in.

Can you clarify that line? I've done this before, but I used the navigation path in the imaginary name - i.e. I might have the PropertyDescriptor.Name report Customer_Company_Name rather than Name, and use the .DisplayName to report something more readable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文