过滤器的DataGridView

编程入门 行业动态 更新时间:2024-10-22 15:22:25
本文介绍了过滤器的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

本文发布于:2023-11-09 21:11:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1573446.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:过滤器   DataGridView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!