Mr

Welcome to Wisej Support.
Questions, suggestions and plain old bugs - are all welcome here!
0
0

Hi, Please how can i enable filtering/sorting on the datagridview?.

  • You must to post comments
0
0

Hi Francis,

I have put together a small sample, that you can download here: http://wisej.s3.amazonaws.com/support/attachments/DgvSortFilter.zip

dgvsortfilter

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:

this.dataGridView1.Sort(dataGridView1.Columns[“Name”], System.ComponentModel.ListSortDirection.Ascending);

And filter the BindingSource that will automatically update the bound datagridview:

bs.Filter = “Town = ‘New York'”;

Hope that helps.

Best regards
Frank

Attachment
  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Attachment
File Name Size
There are currently no files uploaded.
Maximum number of files 1, maximum file size 3.9MB.
Supported file formats: zip pdf gif jpg bmp png cs vb theme json