[RESOLVED] DGV Combined Filter
Hi,
I am filtering a Datagridview with combined help of 4 textboxes and 4 comboboxes each dedicated to a field in DB. All i know about this process is i can combine two or more filters but how do i check at a given time, whether which of these (cb & tb) have been used already to perform the filter already and then collect all the instances and perform the collective filter.
Any suggestions??
Lux.
Re: [RESOLVED] DGV Combined Filter
I am using the following to join the filter string and perform a filter on the DGV. I tried a lot but it gives me error
Quote:
Error 1 Value of type 'System.Collections.Generic.List(Of String)' cannot be converted to '1-dimensional array of String'.
vb Code:
Dim filters As New List(Of String)
If (reader("Category".ToString)).Length > 0 Then
filters.Add(String.Format("(Convert(Category, 'System.String') LIKE '%{0}%')", (reader("Category"))))
End If
If (reader("Type".ToString)).Length > 0 Then
filters.Add(String.Format("(Convert(Type, 'System.String') LIKE '%{0}%')", (reader("Type"))))
End If
Dim filter As String = String.Join(" And ", filters)
ClientProfileBindingSource.Filter = filter
what should i do?
Re: [RESOLVED] DGV Combined Filter
I typed that code straight into the forum so didn't have the IDE to check it for me. That said, the fix is fairly simple. You've got a List(Of String) and you need a String(). How do you create an array from a List? You call ToArray on it.