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

Selection inside ReadOnlyRange

4 Answers 67 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Charles
Top achievements
Rank 1
Charles asked on 30 Jul 2012, 09:56 AM
Hi

At the moment, it isn't possible to click inside a ReadOnlyRange - it is only possible to select it if the selection begins and ends before and after the range.

Ideally I would like to be able to place the cursor inside a ReadOnlyRange and select any part of it, just as I would a non-ReadOnlyRange.  The only difference being that deletion would not be possible.

Is there any workaround or sub-classing of ReadOnlyRange that would make this possible?

Thanks

Charlie

4 Answers, 1 is accepted

Sort by
0
Charles
Top achievements
Rank 1
answered on 30 Jul 2012, 10:32 AM
Should try harder before posting...

I created a new annotation range derived from ReadOnlyRangeStart (and ReadOnlyRangeEnd) with a property overridden as below.  This gives me what I wanted - I assume there's no issue with doing this?

public override bool SkipPositionsInRange
{
    get { return false; }
}

0
Iva Toteva
Telerik team
answered on 31 Jul 2012, 12:54 PM
Hi Charles,

You can create and use custom annotation ranges by inheriting from AnnotationRangeStart and AnnotationRangeEnd or any of the already implemented annotation range elements (FieldRangeStart/End, ReadOnlyRangeStart/End, etc). More information on the properties that can be overridden can be found here.

If you need additional assistance, do not hesitate to contact us again.

Regards,
Iva Toteva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Charles
Top achievements
Rank 1
answered on 08 Aug 2012, 10:33 AM
Hi Iva



I have have another issue - I'm not sure if there's a solution!



What I'd like is a range that is read-only - i.e. the user cannot delete or change the text content within - but I would like them to be able to change the font and styling.



Currently it appears to be one or the other - I can achieve both.  The only conceivable workaround I can think of is replacing most of the styling commands that the ribbon is bound to with my own that allow execution on read-only ranges.  But that sounds like quite a large task!        
0
Iva Toteva
Telerik team
answered on 13 Aug 2012, 06:00 PM
Hi Charles,

You are right - this behavior cannot be that easily achieved. The logic that disables changes to the document when the selection contains read only elements lies quite deep in the code. Unfortunately you will not be able to apply formatting to the read-only parts of the document using the public API. 

We will log this as a feature request, but it is not clear when it will be implemented.

The only way to achieve the desired behavior with the current version is to download the source of the control and change the way the commands are executed in read-only parts of the document.

Greetings,
Iva Toteva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
RichTextBox
Asked by
Charles
Top achievements
Rank 1
Answers by
Charles
Top achievements
Rank 1
Iva Toteva
Telerik team
Share this question
or