C# DataGridView Sorting and Filtering
The DataGridView control is highly configurable and extensible, and it provides many properties, methods, and events to customize its appearance and behavior. A DataView provides a means to filter and sort data within a DataTable. The following C# program shows how to filter and sort a DataGridView by using a DataView.
How to sort Datagridview
The DataGridView control in C# provides automatic sorting, so that you can manually sort any column in the datagridview control. You can sort the data in ascending or descending order based on the contents of the specified column. Also you can see the DataGridView sorting when user clicks on the column header.
In the above code , datagridview sort the title column thats 1st column.
How to filter Datagridview
You can filter datagridview column in many ways. You can sort data while retrieving it from database using order by clause or you can use the following method.
In the above code, datagridview is filter the column Type and value is Business.
- C# DataGridView Binding - SQL Server dataset
- C# DataGridView Binding - OLEDB dataset
- C# DataGridView Add Columns and Rows
- C# DataGridView Hide Columns and Rows
- C# DataGridView Read Only Columns and Rows
- Add Button to C# DataGridView
- Add CheckBox to C# DataGridView
- Add ComboBox to C# DataGridView
- Add Image to C# DataGridView
- Add ViewLink to C# DataGridView
- C# DataGridView Paging
- C# DataGridView Formatting
- C# DataGridView Template
- C# DataGridView Printing
- C# DataGridView Export to Excel
- C# DataGridView Loading data from Excel
- C# DataGridView Database Operations
- Delete row from datagridview by right click
- DataGridView Autocomplete TextBox in C#