Search code examples
c#winformsdatagridviewbindingsource

How can I determine which column has been sorted in a DataGridView when the SortMode is Automatic


Winforms DataGridView

The SortedColumn is always null (expected when SortMode is Automatic) and the bindingSource sort property is always blank.


Solution

  • if i am not wrong DataGridView supports single column sorting, and you can get the sorted column name by

    var sortedCol = dataGridView1.SortedColumn.DataPropertyName;