数据视图过滤 vb.net
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33815330/
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
Dataview filtering vb.net
提问by Jake Pavek
Wondering if I am doing this filter right with the dataview, it keeps throwing me this error
想知道我是否正在使用数据视图正确执行此过滤器,它不断向我抛出此错误
Additional information: Filter expression '80' does not evaluate to a Boolean term.
but here is the code
但这是代码
Dim table = DataSet1.Tables("network")
table.DefaultView.RowFilter = TextBox1.Text
DataGridView1.DataSource = table
回答by Steve
To filter something on a DataVIew you need to specify the column on which the filter should be applied, the operator for the comparison and the value that you want to use for the filtering. It seems that you have given only the value "80".
要在 DataVIew 上过滤某些内容,您需要指定应应用过滤器的列、比较运算符以及要用于过滤的值。似乎您只给出了值“80”。
For example, assuming the column of interest is named "NumberOfPieces" and you have typed 80 in the textbox
例如,假设感兴趣的列名为“NumberOfPieces”并且您在文本框中输入了 80
Dim table = DataSet1.Tables("network")
table.DefaultView.RowFilter = "NumberOfPieces = " & TextBox1.Text
DataGridView1.DataSource = table
This will filter the view with all the rows that have the value (a numeric value) equals to 80 in the column "NumberOfPieces". You could use other operators like Greater/Lesser Than ( >= <= ) or more complex construct that are well detailed in the MSDN page about the Expression property of the DataColumn object
这将使用“NumberOfPieces”列中值(数值)等于 80 的所有行过滤视图。您可以使用其他运算符,例如大于/小于 ( >= <= ) 或更复杂的构造,这些构造在 MSDN 页面中详细介绍了 DataColumn 对象的Expression 属性

