Filtering RadGridView by Multiple Values
Environment
Product Version | Product | Author |
---|---|---|
2024.1.130 | RadGridView for WinForms | Dinko Krastev |
Description
In this tutorial we will demonstrate how to filter RadGridView by a list of values copied from an Excel column without having to use the "is in list" option. We will modify the Custom Filtering demo from our WinForms Demos Application.
Solution
To filter RadGridView by multiple values, you can modify the code from the Custom Filtering demo, by following these steps:
- Modify the
radGridView1_CustomFiltering
event from the Custom Filtering demo. - Check if the filter text is empty. If it is, reset the styles of all cells and make all rows visible.
- If the filter text is not empty, split it into multiple values using a comma as the separator.
- Iterate through each cell in the row and compare its value to each of the filter values.
- If a match is found, make the row visible and customize the fill color of the cell.
- If no match is found, reset the style of the cell.
- End the update of the RadGridView.
Here is the modified code:
Now you can use this modified code to filter the RadGridView by multiple values.