C# DataGridView sorting with Generic List as underlying source

前端 未结 9 1829
情书的邮戳
情书的邮戳 2020-12-05 03:22

I\'m using a Windows Forms DataGridView to display a generic list of MyObject objects.

First of all I wrap this collection into a

9条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-05 03:43

    My Solution is this:

    I work with myBindingSource at my own, I do sorting, grouping ..whatever in a separate thread. Then I simply bind the result to the DataGridView.

    myDataGridView.DataSource = bindingSource;
    

    For this purpose I've setted all the columns to be sorted 'Programatically' (in designer) Then I manually add the arrow (ASCENDING / DESCENDING) by setting

    cell.SortGlyphDirection = ... ; 
    

    in code behind.

提交回复
热议问题