DataGridView reset column sort

0
0

How can you programatically reset (remove) sort from columns and repaint grid as when for is freshly opened?

I can see that most properties tied to sort are read only.

  • Dino Novak
    This is not producing any result: for (int i = 0; i < dgwAssignmentsView.Columns.Count; i++) { dgwAssignmentsView.Columns[i].SortMode = DataGridViewColumnSortMode.NotSet; dgwAssignmentsView.Columns[i].Update(); } this.Update();
  • You must to post comments
0
0

Unfortunately, There is no undoing of a sort via the datagridview itself.
You can reset the sort glyph on the column header.
If it’s a databound grid, you could reset the sort on the data source.
SortMode only controls how each column CAN control the sorting, it doesn’t sort the columns. So that’s why your code snippet does not work.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.