C # Winforms DataGridView with sorting / filtering like Ms Excel

Hey. I need a quick solution for filtering / sorting using a Winforms DataGridView control, as in Excel.

I looked through existing posts in this area, but not one of them fits my needs.

I manually populate my DataGridView - data binding

+5
source share
4 answers

DataGridView columns already support sorting.

I would populate the DataTable with your data and bind the DataGridView to myDataTable.DefaultView.

You can filter the rows displayed by setting myDataTable.DefaultView.RowFilter.

/ DataGridView myDataTable.DefaultView.RowFilter /.

+6

? , . DataGridView , . , AutoFilter Excel.

0

Microsoft has created an example project for VB and C # where they show how to create an "autofiltration" plugin. I personally don’t like it, since it allows you to filter exactly so that the product and the client work, open an account where the price> some cost is not realized

Sorting is done using:

foreach (DataGridViewColumn column in MyDataView.Columns)
{
      column.SortMode = DataGridViewColumnSortMode.Automatic;
}

You do this when the grid has columns, if you automatically create columns ... after binding.

-1
source

All Articles