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

Make document truly read-only

3 Answers 144 Views
RichTextEditor
This is a migrated thread and some comments may be shown as answers.
Mihajlo
Top achievements
Rank 1
Iron
Mihajlo asked on 20 Feb 2019, 04:38 PM

In Word-inspired project I want to display a document and prevent any modifications to it. If I set radRichTextEditor1.IsReadOnly = true then user cannot type in it, but commands from ribbon bar still work (text can be turned bold, for instance). How to disable all the commands from ribbon bar? My document already has document protection enabled, but it also has one permission range.

Interestingly, looking into Telerik code, there is a RichTextBoxCommandBase.CanExecute method, but it's apparently being ignored, as ribbon bar commands are executed even when CanExecute returns false.

3 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 21 Feb 2019, 09:08 AM
Hello Mihajlo,

You can use the CommandExecuting event for this. For example: 
private void RadRichTextEditor1_CommandExecuting(object sender, Telerik.WinForms.Documents.RichTextBoxCommands.CommandExecutingEventArgs e)
{
   e.Cancel = radRichTextEditor1.IsReadOnly;
}

Another approach would be to hide or disable the ribbon or the ribbon tabs when such document is loaded. 

I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
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
Mihajlo
Top achievements
Rank 1
Iron
answered on 21 Feb 2019, 09:39 AM

Right, but that would disable Copy and Find commands. The code below should fix it probably, but I suggest this code run before even reaching CommandExecuting handler:

e.Cancel = !e.Command.CanExecute(e.CommandParameter);

 

Even with this fix there is still a small annoyance that toggle buttons (like Bold) change their toggle state when clicked on protected document. Nothing will happen to the document, and once caret is moved toggle state will be restored, but it looks strange at first. As a reference, Word will disable all appropriate buttons when caret is in protected part of the document.

0
Accepted
Dimitar
Telerik team
answered on 21 Feb 2019, 01:46 PM
Hello Mihajlo,

Ok, I have logged this for improvement on our Feedback Portal. You can track its progress, subscribe to status changes and add your comment to it here. I have also updated your Telerik Points.

Until this is implemented you can use the bellow approach as a workaround. 

Should you have any other questions do not hesitate to ask.
 
Regards,
Dimitar
Progress Telerik
Get quickly onboard and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
RichTextEditor
Asked by
Mihajlo
Top achievements
Rank 1
Iron
Answers by
Dimitar
Telerik team
Mihajlo
Top achievements
Rank 1
Iron
Share this question
or