How to Search and Highlight Text in RichTextEditor
Environment
Product Version | Product | Author |
---|---|---|
2022.1.222 | RadRichTextEditor for WinForms | Desislava Yordanova |
Description
This article demonstrates a sample approach how to search for a certain text in the rich-text document and highlight the find matches:
Solution
The example contains a RadRichTextEditor for displaying the rich-text content, a RadTextBox for the search pattern and a RadButton to trigger the highlight action.
We will use DocumentTextSearch for finding all the TextRanges that match the search pattern. For each found range we will make a selection and highlight the selection with red forecolor and yellow background: