Winform Grid Sorting

Winform Grid Sorting

Old forum URL: forums.lhotka.net/forums/t/8547.aspx


cmay posted on Wednesday, February 17, 2010

I think maybe I'm missing something here.

When I databind a normal businesslist to a windform datagrid, I don't get any sorting functionality out of the grid.   I think this is as expected.

I can simply do:

x.DataSource = new Csla.SortedBindingList(of Y)(Y.FetchList())

and that will cause all the sorting functionality to work correctly.

However, in Rocky's book, he says that SortedBindingList and FilteredBindingList are obsolete with the introduction of LINQ. 

Am I correct in thinking that using the sortedbindinglist would still be the ideal way to get sorting in a winform grid?  I don't see any simple way to get the same results using linq.

 

ajj3085 replied on Wednesday, February 17, 2010

Well, they are and they aren't.  They're obsolete really because of Wpf and SL, and WinForms is now being considered legacy technology. 

But if you're still on WinForms, you should continue to use those classes if needed, because WinForms doesn't understand Linq.

cmay replied on Wednesday, February 17, 2010

Thanks for verifying that for me.  I wasn't sure.

Any idea why the Sorting and Filtering were not built into BusinessListBase back before Linq was an option?

ajj3085 replied on Wednesday, February 17, 2010

I think its because there's overhead associated with it, and if you don't need it you'd still pay the price. Sorting and filtering is often though just a UI concern, and so shouldn't be part of the business layer. Csla provided those as a convience.

JonnyBee replied on Saturday, February 20, 2010

Hi,

Sorting/Filtering is usually closely connected to functionality in the UI and as such should not be in the core BusinessListBase.

DataSets implement the IBindingListView interface (that supports sorting/filtering) but unfortunately - there is no generic implementation from Microsoft available. There is one open source implementation on SourceForge tho'.

Copyright (c) Marimer LLC