我有一个自定义属性描述符,用于支持展平对象层次结构。
为了实现这一点,我对 PropertyDescriptor
进行了子类化,并将一个链表存储到我要检索其值的“下一个”(子)属性。
这使我能够以“平面”方式将子属性绑定(bind)到网格(导出到 excel 等)。
例如。 网格(绑定(bind)属性,标题)
Col1:Customer.Name(Customer)
Col2:Customer.Address(Address)
Col3:Customer.OutstandingOrders.Count(Outstanding Orders)
问题是,一旦我添加了一个具有重复名称的列,无论它是否具有唯一的标题,它都会检索第一个的属性,但仍将正确的标题放入:
Col4:Customer.Company.Name(Company)
有什么想法吗?
最佳答案
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.
你能澄清一下那条线吗?我以前做过,但我使用了假想名称中的导航路径 - 即我可能有 PropertyDescriptor.Name
报告 Customer_Company_Name
而不是 Name
,并使用 .DisplayName
来报告更具可读性的内容。
关于c# - 自定义属性描述符和扁平化层次结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/784742/