.NET / WinForms - Clear a Sort on a DataGridView

BuddyJoe picture BuddyJoe · Sep 9, 2009 · Viewed 13.6k times · Source

What is the proper method to tell a DataGridView to stop sorting?

I have a "screen" where I tell the grid programatically to sort by column 4 and ascending. When I switch to another area I want the same grid to come in 'default'/no sort. I'm removing all the columns and adding new ones. The sort remains on the 4th column.

I don't see a way to do this with the Sort() method. Any ideas?

Answer

Ken picture Ken · Sep 24, 2009

I've accessed the sort on the BindingSource directly:

((BindingSource)_dgv.DataSource).Sort = string.Empty;