How to disable sort in DataGridView?

Gold picture Gold · Dec 21, 2010 · Viewed 110k times · Source

How can I disable sort in DataGridView? I need to disable the header DataGridView sorting.

Answer

hunter picture hunter · Dec 21, 2010
foreach (DataGridViewColumn column in dataGridView.Columns)
{
    column.SortMode = DataGridViewColumnSortMode.NotSortable;
}