C# 如何重置 table.DefaultView.RowFilter?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1009932/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 05:28:08  来源:igfitidea点击:

How can I reset table.DefaultView.RowFilter?

c#datatableresetrowfilterdefaultview

提问by

The code below works fine and filters the rows correctly but how would I restore the table to its original state?

下面的代码工作正常并正确过滤行,但如何将表恢复到其原始状态?

DataTable table = this.dataGridView1.DataSource as DataTable;
table.DefaultView.RowFilter = comboBox.Text + " LIKE '%" + strName + "%'";

Thanks

谢谢

采纳答案by Muad'Dib

try this:

尝试这个:

table.DefaultView.RowFilter = string.Empty

回答by Jervie Vitriolo

This is the best tweak:

这是最好的调整:

table.DefaultView.RowFilter = "1=1";

回答by Morten Finnerud

This works also like a charm:

这也像一个魅力:

table.DefaultView.RowFilter = null /Nothing