使用组合框或文本框过滤DataGridView [英] filtering DataGridView with combobox or textbox

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

问题描述

我有一个称为podaci的表,在该表上有一个绑定到podaci的DataGridView.我想要组合框或文本框,无论哪种方式,当我在podaci中键入多个特定列时,都只能在DataGridView中显示该行.基本上我需要一个过滤器.

任何人都可以帮助我?????

I have one table called podaci, one form on which I have DataGridView which is bound to podaci. I want to have combobox or textbox, whichever in which when I type a number of one specific column in podaci so it only shows that row in DataGridView. basically I need a filter for it.

anyone can help me ?????

推荐答案

私有无效txtPretragaB_TextChanged(对象发送方,EventArgs e)
{
this.podaciBindingSource.Filter = string.Format("Bankomat LIKE \" {0}%\";, this.txtPretragaB.Text);
}


我做的!!!!!!这有效

没有按钮,只要输入我想要的内容,它就会过滤掉除文本框中的内容以外的所有内容
private void txtPretragaB_TextChanged(object sender, EventArgs e)
{
this.podaciBindingSource.Filter = string.Format("Bankomat LIKE \''{0}%\";, this.txtPretragaB.Text);
}


I DID IT!!!!!! this works

no button, just typed in what I want and there it is, it filters everything out except what I have in textbox


将表值分配给Data视图对象.数据视图具有过滤器选项.
dataView.RowFilter ="ColumnName =``约翰''''

在这里,您可以传递textbox/Combobox中提供的任何值来代替"Jhon".

将dataview分配给Gridview.datasource.
Assign table values to Data view object. Data View has filter option.
dataView.RowFilter = "ColumnName = ''John''"

Here in place of ''Jhon'' you can pass whatever value is provided in textbox/Combobox.

Assign dataview to Gridview.datasource.


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

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