Highlight Filtering Results by using HTML-like text formatting in RadListView
Environment
Product Version | Product | Author |
---|---|---|
2020.1.113 | RadListView for WinForms | Nadya Karaivanova |
Description
This tutorial demonstrates how to highlight text results both backcolor and forecolor when filtering in RadListView by using HTML-like text formatting approach.
Solution
First, I would like to note that HTML-like text formatting uses uses GDI+ to measure and render the text. You can find more information about text rendering here.
The desired text highlight effect can be achieved by subscribing to the VisualItemFormatting event that provides a convenient way for customizing the items appearance. In this event you have access to the ListViewDataItem via the VisualItem.Data property. Then, you can separate the text to a small parts by the searched symbol/s. Finally, you can use the HTML-like text formatting to apply a specific look of the text parts accordingly.
A full code snippet is illustrated below: