Hi,
I would like to disable sorting in a winform datagrid when a column header
is clicked.
The following does *not* seem to disable sorting and clicking the column
header still sorts the grid:
After loading data into the dataset:
{
....
this.dataGrid1.DataSource = this.ds1.tableA;
System.Data.DataView dv = this.ds1.tableA.DefaultView;
dv.AllowNew = false; // no append row
dv.AllowDelete = false; // no delete row
dv.Sort = ""; // no sort string <------- ????
dv.ApplyDefaultSort = false;
....
}
Also in the mouse down/up events:
{
....
Point pt = new Point(e.X, e.Y);
DataGrid.HitTestInfo hti = dataGrid1.HitTest(pt);
if( hti.Type == DataGrid.HitTestType.ColumnHeader )
return; // don't sort: don't call baseclass !!!
base.OnMouseUp(e); // ... or OnMouseUp
}
Thanks in advance
Mike