I've created a reusable UI control that encapsulates a DataGridView and allows filtering with the FilterableCollectionBase.
I wanted to make the class generic in order to specify a RootList for the rows and a Child type to reflect upon for enabling features of the control. I ran into the problem that VisualStudio2005 will not allow me to put a control implemented as a generic class into the ToolBox. To get around this problem I created a "generic method" so the UI developer can still specify a list and child type.
public void SetDataSource<T>(IList<T> list, Type type )
I can set the datasource to the full list or to a filtered list depending on user input through the control. The user can use the column headers to sort based on the column values. This works well for sorting 'OR' for filtering. The problem I've encountered is when the user filters the original list and then clicks the column header of the DataGridView to sort the filtered rows. The DataGridView throws an exception stating "DataGridView control cannot be sorted if it is bound to an IBindingList that does not support sorting."
It appears that the FilterableCollectionBase returns a collection that does not support sorting. It would seem that an easy solution would be to pass the filtered collection through SortedBindingList<T> to get a sortable collection before setting it to the datasource of the DataGridView. My problem here is that the type inference <T> is only valid within the generic method.
Is there a way to instantiate a SortedBindingList<T> with only a reference to the list?
Has anyone made FilterableCollectionBase sortable?
Has anyone else out there run into similar problems?
Any help would be appreciated.
Thanks,
Pat
I went to www.lhotka.net/cslacvs but can't find a 2.1 branch
Maybe I'm lacking investigative skills, however, I'm unable to find the 2.1 branch in cvs. I was hoping to play around with and possibly finish the incomplete FilteredBindingList<>. Is this missing or am I blind? Thanks in advance.
Copyright (c) Marimer LLC