Hello Mihajlo,
With the current approach, there is a direct change in the model of the document. As a result, the rendering is not notified of the change, thus it is not updated. What you can do to update the document is to invoke the
InvalidateMeasureUpToTheRoot() method on each of the layout boxes that are changed and the
UpdateEditorLayout() of RadRichTextBox to force the measuring processes and update the visualization.
My concern here is that using this approach might be a bit risky - the layout boxes are responsible for the rendering and a single span can be represented by several layout boxes. This on its turn, might lead to incorrect behavior in the application. For example, a span can be separated in different layout boxes if a part of its letters has a different styling.
What I can suggest as an alternative implementation is to use the
DocumentTextSearch class, which allows you to apply a particular range to
search inside through the overloads of the
Find() method. You can iterate the ranges of the selection, obtain their positions and perform the search operation on them. Something to note here is that would be a better solution to iterate the selection ranges and the matches from the search backward - from the last item to the first one to avoid additional updates.
Hope this information is helpful.
Regards,
Tanya
Progress Telerik
Get
quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers.
Learn More.