Windows Forms: Advanced Filter DataGridView in C#

Filter DataGridView by columns in C# step by step

Step 1Click New Project, then select Visual C# on the left, then Windows and then select Windows Forms Application. Name your project "AdvancedDataGridViewDemo" and then click OK

advanced datagridview c#Step 2: Right click on your project select Manage NuGet Packages -> Search AdvancedDataGridView -> Install

c# advanced datagridview

It's a Windows Forms DataGridView Control with Excel-Like auto-filter context menu. Support Localization (currently RU, EN, FR)

Step 3: You need to create a dataset, then add a customer table from Northwind database to your dataset

c# dataset

Step 4: Design your form as below

filter datagridview in c#

Add a bindingsource to your DataGridView

c# bindingsource

Step 5: Add code to handle your winform as below

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace AdvancedDataGridViewDemo
    public partial class Form1 : Form
        public Form1()

        private void Form1_Load(object sender, EventArgs e)
            // TODO: This line of code loads data into the 'northwindDataSet.Customers' table. You can move, or remove it, as needed.


        private void advancedDataGridView_SortStringChanged(object sender, EventArgs e)
            this.customersBindingSource.Sort = this.advancedDataGridView.SortString;

        private void advancedDataGridView_FilterStringChanged(object sender, EventArgs e)
            this.customersBindingSource.Filter = this.advancedDataGridView.FilterString;

        private void customersBindingSource_ListChanged(object sender, ListChangedEventArgs e)
            lblTotal.Text = string.Format("Total rows: {0}", this.customersBindingSource.List.Count);