我在网上搜索了我的问题的解决方案,我和我的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
发布评论