[]
        
(Showing Draft Content)

Find and Replace

C1Editor provides asynchronous APIs for searching, highlighting, and replacing text within editor content.

These APIs support scenarios such as:

  • Document search

  • Text highlighting

  • Content replacement

The available methods include:


Highlight Text

FindAndDecorateAsync searches editor content and applies visual formatting to matched text.

The following example highlights occurrences of "Important" using a yellow background.

var count = await c1Editor1.FindAndDecorateAsync(
    "Important",
    styles: "background-color: yellow");

if (!count.HasValue || count == 0)
{
    // no matches found
}

C1WinForms Editor - FindAndDecorateAsync highlighting text


Replace Text

FindTextReplaceAsync searches editor content and replaces matched text with the specified value.

The following example replaces occurrences of "Nikola" with "Nick".

await c1Editor1.FindTextReplaceAsync(    text: "Nikola",
    newText: "Nick");

Text

Replaced Text

C1WinForms Editor - Default text before using FindTextReplaceAsync

C1WinForms Editor - Default text being highlighted after using FindTextReplaceAsync