[SOLVED] Grid problem

Answered Closed
0
0

When I click a column header for sorting application  and then aplication has a error.

 

Test project link :

http://www.huzursoft.com/TestGridProject.rar

  • You must to post comments
Best Answer
0
0

Thank you for the sample.

The issue in the sample is that .ToList() converts the table to a list and .NET lists don’t support column sorting. They have only one Sort() method which either uses the default comparer or requires a custom comparer.

In you sample you can simply assign the Table<customer> to the data source:

             dataGridView1.DataSource = veri.customers; // instead of dataGridView1.DataSource = veri.customers.ToList();

In alternative, if you want to sort the list you need to implement a SortableBindingList<T>: http://stackoverflow.com/questions/23661195/datagridview-using-sortablebindinglist

HTH

Best,

Luca

 

 

  • You must to post comments
Showing 1 result