我有这样的表:
名称|号码
CBC | 5
CBA | 3
CAB | 6
并设置行过滤器:
(table.DataSource as System.Data.DataTable).DefaultView.RowFilter = " number > 0 and name like 'C%' ";
可以暂停过滤或停止刷新表(暂时)以查看例如:
名称|号码
CBC | 5
CBA | 0
CAB | 6
当我手动将3改为0时?
答案 0 :(得分:0)
我找到了解决此问题的方法:
我添加列添加我的表是:
id | name | number
1 | CBC | 5
2 | CBA | 3
3 | CAB | 6
和冻结结果的代码是我想要的:
(table.DataSource as System.Data.DataTable).DefaultView.RowFilter = " number > 0 and name like 'C%' ";
string ids;
foreach (DataGridViewRow row in table.Rows)
{
if (row.Visible)
{
if (ids.Length > 2)
{
ids = ids + " or ";
}
ids = id + " id = '"+row.Cells["id"].Value.ToString()+"' ";
}
}
(table.DataSource as System.Data.DataTable).DefaultView.RowFilter = ids;