Hi,
When you use a list that contains object interfaces rather than the objects themselves (e.g List<IDisplayMe>), the PopulateColumns routine populates the grid with fields defined in the specified interface. Problem is that if the interface is a descendent of some other interface, the fields of that other interface are not included as they should be. The attached code shows an example where IClass3 descends from IClass2 which itself descends from IClass1. Class3 implements IClass3 and therefore must also implement IClass1 and IClass2. The form shows two grids, the datasource of the first is List<IClass3> and the second gets List<Class3>. The first grid displays only the field specifically defined by IClass3. The second grid (correctly) displays all the fields. It seems to me that PopulateColumns does a 'shallow' look at the properties and does not iterate over any hierarchy that may be present. This does not seem right to me.
\The driver for this is that we communicate with actual data from different databases and different structures. The data is used for different things- The implementation of these data connections packs/unpacks data into a common set of formats defined by interfaces and so the grid is unaware of nasty bits of implementation in the actual data classes themselves. e.g realworld:
The base interface contains common data for an 'event' of some kind: a name, a location, a description. The first child interface contains contains times and a guestlist. It's an event that is 'schedulable' but cannot be executed until a date is set for it. A descendent of the second interface provides the date and other stuff. So it's possible to differentiate between a 'potential' event and an actual event as the potential event has no field for 'Date'. But in at least one data display we want to see the lot. So we use interface3. Unfortunately all we see is the Date and Other Stuff…
In the example, I am aware that if I specify all the fields in I1 and I2 in I3 itself, the columns are populated correctly. But that makes no sense programmatically, generating messy code that is wayyy breakable, and makes 'subclassing' the interfaces a pointless exercise, even though in programming terms its bloody fantastic!
I would be interested in what you think about this. Have I missed something obvious?
cheers
>a