如何将组合框选择的文本和文本框添加到行过滤器 [英] how to add combobox selected text and textbox to rowfilter

查看:101
本文介绍了如何将组合框选择的文本和文本框添加到行过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个datagrid视图,当我从组合框中选择列(表中有12列)并单击按钮时,需要根据搜索文本框和一个组合框进行过滤,然后显示已过滤的项目.我的问题是,我可以像下面的代码这样顽固地工作,仅适用于该特定列而不适用于其他列

hi i have a datagrid view which i need to filter based on search textbox and one combo box when i select the column from the combobox (there are 12 columns in my table) and click button the filtered items should display. my problem is like i can hardcore like below this code works only for that particular column not for the other columns

table.DefaultView.RowFilter = "USER_NAME='" + txtSearch.Text + "'";




它仅显示一列,我应如何对所有十二列进行编码?

有人请帮助我




it displays for only one column how should i do the code for all tweleve columns ?????


someone pls help me

推荐答案

您可以在RowFilter中指定多个条件.您可以形成与SQL非常相似的表达式.

详细信息在这里:
MSDN:DataColumn.Expression属性 [ MSDN:DataView.RowFilter属性 [
You can specify multiple conditions in the RowFilter. You can form the expression which is quite similar to SQL.

Details here:
MSDN: DataColumn.Expression Property [^]
MSDN: DataView.RowFilter Property[^]

Sample:
myDataView.RowFilter = "Name = 'Sandeep' AND JoinDate > '1/1/2010'"; 


这篇关于如何将组合框选择的文本和文本框添加到行过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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