C # How to sort columns in datagrid in alphabetical order?

How to sort columns in a winforms datagrid control in alphabetical order?

thanks

+5
source share
3 answers

Have you tried to bind a DataGrid to a DataTable (instead of a view) and turn the value of the AllowSorting property into true in the DataGrid? I believe the grid will automatically sort the table source for you.

If not, you can always catch the event when you click the column heading and rebuild the DataView to bind to the DataGrid.

+1
source

This MSDN article should guide you along the way.

, , .

+1

My items are usually lists of items in memory. With data binding networks, you need to sort the data in the source, not in the grid itself.

Here the code for my list is sorted. Maybe this will give you an idea of ​​getting out of place.

http://jspot.jerryhanel.com/2012/06/28/sort-your-databound-grid-effortlessly/

0
source

All Articles