This is a migrated thread and some comments may be shown as answers.

How to use InsertReadOnlyRange from RadDocumentEditor

2 Answers 65 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Pavel
Top achievements
Rank 1
Pavel asked on 11 Jun 2019, 07:27 PM

Hi all,

I am updating some code and it appears the use of InsertReadOnlyPage(DocumentPosition start, DocumentPosition end) from RadDocument is obselete and replaced by RadDocumentEditor.InsertReadOnlyPage().

 

The original call was the following (note the parameters):

1.editor.Document.InsertReadOnlyRange(start, end);

Would this be equivalent the equivalent update?

1.RadDocumentEditor _radDocEditor = new RadDocumentEditor(editor.Document);
2._radDocEditor.Document.Selection.AddSelectionStart(start);
3._radDocEditor.Document.Selection.AddSelectionEnd(end);
4._radDocEditor.InsertReadOnlyRange();

2 Answers, 1 is accepted

Sort by
0
Boby
Telerik team
answered on 14 Jun 2019, 03:42 PM
Hello Pavel,

You guessed this correctly, RadDocumentEditor works with the current selection (RadDocument.Selection) and position (RadDocument.CaretPosition) of its associated RadDocument.

Just a small tweak, which might not be relevant, but still -  DocumentSelection.AddSelectionStart(*) will start adding new range to the selection, meaning that if you call this method multiple times, it will create selection with multiple ranges. Instead, you can use DocumentSelection.SetSelectionStart(*), which clears the current selection before starting the creation of a new range.


Regards,
Boby
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.
0
Pavel
Top achievements
Rank 1
answered on 14 Jun 2019, 03:50 PM
excellent. Yeah, I think I will have to perform a reset of the selection since we are dealing with a fresh selection based on the original premise of the original method.
Tags
RichTextBox
Asked by
Pavel
Top achievements
Rank 1
Answers by
Boby
Telerik team
Pavel
Top achievements
Rank 1
Share this question
or