I have a helper class that implements ITypedList, to provide objects for databinding against custom collections.
My implementation allows me to easily specify that I want sub-properties of objects to be available for data binding, for instance I can bind to "Id", "Name", and also "Children.Count".
Now, my problem now is that in order to provide helper-objects to data-bind to such columns, I need to pre-populate a collection with those objects, and then later on when a grid asks for such helper objects through the interface, it will call a method on my object to retrieve them.
The method it calls has a parameter that can be used to specify which accessor objects to retrieve, but it's invariably null for the .NET DataGridView class, which means I just have to return all the objects I got.
So my question is this. Is there an alternative to ITypedList that I can implement where I will be told explicitly which properties the grid is interested in, so that I don't have to pre-populate the collection of acccessor objects?
Here's what my code looks like now:
var wrapper = new TypedListWrapper<Person>(someNormalCollectionClass);
wrapper.BindableProperties = "Id;Name;Children.Count";
grid.DataSource = wrapper;
here's what I want it to look like:
grid.DataSource = new TypedListWrapper<Person>(someNormalCollectionClass);
Any takers?