RadDocument Span element does not reflect change to forecolor in the UI

1 Answer 27 Views
RichTextBox
Kevin
Top achievements
Rank 1
Kevin asked on 08 Jul 2022, 01:34 PM

In code behind, when a user moves the curser in the RadRichTextBox, we check information tagged to span elements. For certain spans, we want the contents to change color, so we set span.ForeColor to a new value, but this doesn't reflect in the UI. I assume there is some update mechanism, but it isn't obvious. I can select the entire span, copy, and paste it in place and it will show the new color, but we want it to happen when a user is moving the cursor.

We're tracking the cursor in the RadDocument.CaretPosition.PositionChanged event handler.

 

1 Answer, 1 is accepted

Sort by
0
Tanya
Telerik team
answered on 11 Jul 2022, 01:24 PM

Hello Kevin,

When modifying a document that is already visualized, we suggest using the API provided by the RadDocumentEditor or RadRichTextBox classes. These classes are designed to update anything after modifying a property or content so the change can be reflected in the UI as well. Both classes implement the same interface and no matter the one you will choose to use, you can directly invoke the ChangeForeColor method. Any update applied through these classes is performed on the selected content or on the element under the caret if the selection is empty.

Hope this is helpful.

Regards,
Tanya
Progress Telerik

The Premier Dev Conference is back! 

Coming to you live from Progress360 in-person or on your own time, DevReach for all. Register Today.


Kevin
Top achievements
Rank 1
commented on 11 Jul 2022, 01:36 PM

Thank you, I will give this a try.
Tags
RichTextBox
Asked by
Kevin
Top achievements
Rank 1
Answers by
Tanya
Telerik team
Share this question
or