Sort multiple columns while using a bindingsource or bindinglist

Posted by JF on Stack Overflow See other posts from Stack Overflow or by JF
Published on 2010-03-08T20:09:06Z Indexed on 2010/03/08 20:36 UTC
Read the original article Hit count: 672

Hi everyone.

I have a problem I am trying to fix and it's sorting a DataGridView on multiple columns. I have read that this option is not a feature built-in the DataGridView and I have to implement it. I have found multiple solutions, but none quite got to do the work.

I'm also quite a newbie in C# and I don't know much of the .Net library. I have also read on the MSDN site for info on different classes that might be of use, but no success.

Now, let's get to the point. I have a DataGridView, with a BindingList (originally, a BindingSource) that I want to sort, but by multiple keys. My DataGrid has 9 columns and the user should be able to sort on any column. For example, let's say my Datagrid has 3 columns, named : Index, ID, Name. The user wants to sort by Name, implicitly, the next order would be Index and then ID. So, in case 2 names are identical, Index should be the next sort option.

Any ideas how this can be made?

© Stack Overflow or respective owner

Related posts about c#

Related posts about sort