Click here to Skip to main content
15,666,947 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello everyone...
I want to be able to use a filter in my datagridview but i dont know how to do it...
Can anyone pls help me out...

If a comboBox in columnHeader will solve your problem you must inherit a class from DataGridViewColumn and a class inherit from for example DataGridViewTextBoxCell and set cellTemplate of datagridview to second class in DataGridViewColumn Constructor.
After that you must add your desired control into your custom column.You can build that by usercontrol or if you want you can use a comboBox or something like that.
The all inherited classes have paint method that you can override and use the cellbounds to get proper location for your control.
Share this answer
sinh dhqn 22-Jul-13 5:15am    
How do filter datagridview data ?
DataGridView Filter Popup[^] is a good filter implementation for you to look at.
This[^] is a good article on implementing a filter as well.
Datagridview with filtering capability[^] is another nice article.
You can user DataViewRowState to filter data. Use DataViewRowState to filter DataGridView[^] explains this approach.

If you are looking for implementing a search, go through[^].
Share this answer
NandaKumer 14-Dec-11 21:51pm    
nice one

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900