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

How to determine if current position is in editable range

2 Answers 101 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 25 Aug 2014, 01:10 PM
How can I determine if the current caret position in a RadRichTextBox is within a range that is editable?

Thanks.

2 Answers, 1 is accepted

Sort by
0
Accepted
Petya
Telerik team
answered on 28 Aug 2014, 09:52 AM
Hi Chris,

That depends on the approach you are using to restrict editing in your document. For example, if you are using the Document Protection feature and protection is enforced over the current document, here is how you can obtain the range where the caret is located and determine if the current user has rights to edit:
var range = this.radRichTextBox.Document.GetContainingAnnotationRanges<PermissionRangeStart>(this.radRichTextBox.Document.CaretPosition.GetCurrentInline()).First();
 if (range != null)
 {
     bool canEdit = this.radRichTextBox.ProtectionAuthenticationProvider.CanEdit(range.Info);
 }

I hope this is useful.

Regards,
Petya
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Chris
Top achievements
Rank 1
answered on 28 Aug 2014, 12:36 PM
Thank you. That gives me the information I need.
Tags
RichTextBox
Asked by
Chris
Top achievements
Rank 1
Answers by
Petya
Telerik team
Chris
Top achievements
Rank 1
Share this question
or