How to Prevent Applying Formatting To Other Columns In RadGridView CellElements
Environment
Product Version | Product | Author |
---|---|---|
2022.3.913 | RadGridView for WinForms | Maria Terzieva |
Description
A common requirement is to apply style settings to the RadGridView's cell elements. Using the CellFormatting event is a good approach to achieve it. However, the applied style settings might be applied to undesired cell elements after operations like scrolling, grouping, etc.
Undesired formatting
Solution
Due to UI virtualization in RadGridView, the cell elements are created for only visible cells and reused during operations like scrolling, filtering, grouping, etc. In order to prevent applying the formatting to other columns cell elements all customization should be reset for the rest of the cell elements in the CellFormatting event, which is used to access and change the styles of the data cells in the RadGridView. In other words, each "if" statement that applies certain style settings should have the respective "else" clause for resetting these settings. Here is presented a .gif example after resetting all customization of the cell elements: