views:

278

answers:

1

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?

A: 

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.

Marc Gravell
Ahh, I see,I'll try this, I currently return the last child's name (ie this.child==null ? this.name : this.child.name;I'll try it building a unique name like that as I think it's caching the value for the first property and reusing it with the correct caption on the 2nd property.I would vote you up but I cant :(I'll let you know.
John B
Works perfectly, thanks :)
John B
This is the new working line in the Name override.return base.Name + (childProperty == null ? "" : "_" + childProperty.Name);I was previously returning base.Name if childProperty == null or childProperty.Name elsewise.
John B