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

Bring CustomAnnotation Into View

2 Answers 61 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 11 Oct 2012, 10:50 PM
Hi,

My document contains a lot of custom annotations, where each annotation has self generated unique ID.
Is it possible to bring a defined annotation into view based on its ID value?

i.e. If the annotation in question is at the top of the first page, but currently I have the last document page in view, can I make radrichtextbox auto scroll to the annotation when required?

Is it just the case of enumerating through the document searching for the specific annotation ID then setting the caret position to the position of the found annotation field?

foreach (AnnotationRangeMarkerBase annotationMarker in paragraph.EnumerateChildrenOfType<AnnotationRangeMarkerBase>().ToList<AnnotationRangeMarkerBase>())
{
     //....
     //Move caret to annotation if ID field is a match
     //....
}


Thank you for your time,

Rob

2 Answers, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 16 Oct 2012, 12:37 PM
Hello Rob,

In order to implement the behavior you are describing you'd have to find the annotation that fits the criteria - in your case to find the one with the matching ID. Then you can force the caret to the beginning of the respective annotation. Enumerating through all annotations is a valid way to find a specific one, however I would recommend to cache your annotations, for example in a Dictionary in order to improve the performance.

After finding the annotation start/end you are looking for, you can use the MoveToInline method of the caret.
 
 
Kind regards,
Petya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Robert
Top achievements
Rank 1
answered on 16 Oct 2012, 12:44 PM
Thanks Petya, I will give it a go,
Tags
RichTextBox
Asked by
Robert
Top achievements
Rank 1
Answers by
Petya
Telerik team
Robert
Top achievements
Rank 1
Share this question
or