2
我使用位于http://blw.sourceforge.net/的BindingListView DLL来启用对具有通用列表的DataGridView进行排序,因为它是DataSource。我阅读过滤,它使用起来相当简单,但我在试图弄清楚如何使用过滤器的多个搜索参数时遇到问题。下面是一个例子...使用BindingListView进行多列筛选
Private Sub txtProjectNumber_TextChanged(sender As Object, e As System.EventArgs) Handles txtProjectNumber.TextChanged, txtDescription.TextChanged,
txtOracleNumber.TextChanged, txtBudgetYearFrom.TextChanged, txtBudgetYearTo.TextChanged, txtWeek3Start.TextChanged, txtWeek3End.TextChanged
view.ApplyFilter(AddressOf FilterData)
End Sub
Private Function FilterData(ByVal projectDetails As ProjectDetails) As Boolean
Try
If Not String.IsNullOrWhiteSpace(txtProjectNumber.Text) Then
Return projectDetails.ProjectNum.ToLower().StartsWith(txtProjectNumber.Text.ToLower())
End If
If Not String.IsNullOrWhiteSpace(txtDescription.Text) Then
Return projectDetails.Description.ToLower().StartsWith(txtDescription.Text.ToLower())
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Return False
End Function
所以在这里你可以看到,如果我更改txtProjectNumber文本框中的文本我过滤器将返回正确的结果。但是如果我在txtProjectNumber TextBox中放置了“x”,并且还希望通过“morning”的txtDescription进行搜索,则txtDescription会被忽略,因为它会触击txtProjectNumber并返回,而不会触及txtDescription文本框。我怎样才能让它继续下去,从每个非空输入建立一个过滤器?