I have put together a small sample, that you can download here: http://wisej.s3.amazonaws.com/support/attachments/DgvSortFilter.zip
The datagridview is populated from a BindingSource created by a DataTable. All columns can be sorted by default by clicking on its column header.
In my sample I want to prevent the ID column from being sorted by the user with the following code:
this.dataGridView1.Columns[“ID”].SortMode = DataGridViewColumnSortMode.NotSortable;
Then I added 2 buttons to show how to sort / filter by code:
And filter the BindingSource that will automatically update the bound datagridview:
bs.Filter = “Town = ‘New York'”;
Hope that helps.