过滤器的DataGridView [英] Filter DataGridView

查看:183
本文介绍了过滤器的DataGridView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网上搜索了我的问题的解决方案,我和我的studygrp正在一个DataGridView,从classLibrary需要的信息。所有的作品,但现在我们得到了过滤,但所有我能找到的是由BindingSource的,但是这不是我在想什么。我只想要一个简单的过滤器,这样就可以进入一个文本框的东西,这也显示出对datagridview的,如果它包含的信息。我试过:

I've searched the internet for a solution for my problem, me and my studygrp is making a datagridview that takes information from a classLibrary. All that works but now we got to filter it but all I can find is by bindingsource but that's not what I was thinking. I just want a simple filter so that you can enter something in a textbox and it shows it on the datagridview if it contains that information. I've tried:

((DataTable)dataGridView1.DataSource).DefaultView.RowFilter = "FromColumn like '%" + textBox1.Text + "%'";



但它不工作就像我希望它hmmn ......任何人都可以帮助?

But it doesn't work like I want it to hmmn... anyone that can help?

推荐答案

尝试的BindingSource。它提供了过滤

Try BindingSource. It provides good extensive facilities of filtering

BindingSource bs = new BindingSource();
bs.DataSource = dataGridView1.DataSource;
bs.Filter = "yourColumnName like '%" + textBox1.Text + "%'";
dataGridView1.DataSource = bs;

这篇关于过滤器的DataGridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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