First of all I load an excel file to an datagrid. No prob.
Then I have 2 'checkedlistboxes', so more choices for an filter.
I think my code is correct but the filter does'nt work correctly.
Code how I read the values for the checkedlistboxes and put the values in a string with a filterformat =
Ok this works correct it gives me ae = "TYPE = 'food' OR TYPE = 'horeca'"
Dim s AsString = "TYPE = '"
If CheckedListBox1.CheckedItems.Count <> 0 Then
Dim x AsInteger
For x = 0 To CheckedListBox1.CheckedItems.Count - 1
s = s & CheckedListBox1.CheckedItems(x).ToString & "' OR TYPE = '"
s = s.Remove(s.Length - 12)
Then I have a 2nd filter which works the same but it put the values in an other string (t) + it make ae = "REGIO = 'Waregem' OR REGIO = 'Kortrijk'"
Then I put the 2 strings together and bind an "AND" between so we get "TYPE = 'food' OR TYPE = 'horeca' AND REGIO = 'Waregem' OR REGIO = 'Kortrijk'"
This is correct because I checked it with a messagebox.
Put this together happens in the filter below
Then I put this in a filter , the code is:
So whats the problem.
Dim dv AsNewDataView
dv = NewDataView(ExcelDataSet.Tables(0), s & " AND " & t, "TYPE Desc", DataViewRowState.CurrentRows)
DataGridView1.DataSource = dv
If I check 1 value on the 2 filters. It works correctly. If I check more then it shows not the right result.
Can it be that the filter only works with 1 or 2 arguments? and not with 3,4,5?