我们如何从C#中的datagridview获取应用于列的过滤器的值? [英] How do we get the value of filter applied in the columns from a datagridview in C#?

查看:61
本文介绍了我们如何从C#中的datagridview获取应用于列的过滤器的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须获取过滤器的值并将其存储,然后在刷新后将此过滤器值重新应用于datagridview。请建议最有效的方法。



我尝试过:



我尝试从datagridview.datasource获取过滤器,在即时窗口中我可以看到应用了过滤器字符串,但我不知道如何从datagridview.datasource获取过滤器的值。

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.

推荐答案

尝试这个(我在谷歌找到它)。如果你不介意假新闻过滤,那么获取代码是一个非常好的地方。

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);


这篇关于我们如何从C#中的datagridview获取应用于列的过滤器的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆