I have a DataGridView
column header. When I click that header, the data is resorted according to the value.
I don't want that.
DataGrid
has an AllowSort
property. DataGridView doesn't have that. Anything I can do?
You have to set that on the columns. For example,
dataGridView1.Columns["MyColumn"].SortMode = DataGridViewColumnSortMode.NotSortable;
You can override OnColumnAdded function:
protected override void OnColumnAdded(DataGridViewColumnEventArgs e)
{
base.OnColumnAdded(e);
e.Column.SortMode = DataGridViewColumnSortMode.NotSortable;
}
You can disable auto sort for each and every individual cells in your DataGridView:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With