Click here to Skip to main content
15,902,908 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have to get the value of the filter and store it and then re-apply this filter value back to the datagridview after refresh. Please suggest the most efficient way to do this.

What I have tried:

I tried getting the filter from datagridview.datasource and in the immediate window I can see the filter string applied, but I do not know how to get the value of the filter from the datagridview.datasource.
Posted
Updated 3-Jan-17 4:18am

1 solution

Try this (I found it with google). If you don't mind the fake news filtering, it's agreat place to get code.
(dataGridViewFields.DataSource as DataTable).DefaultView.RowFilter = string.Format("Field = '{0}'", textBoxFilter.Text);
 
Share this answer
 
Comments
Member 12932672 3-Jan-17 13:26pm    
Thank you John for the reply. I have the filter value in the datagridview.datasource but I do not know how to get the value out of it. Could you please suggest something. Thanks

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