Here is a code sample that gets the Type Of the Next & Previous Annotation at the caret position.
.
Get TypeOf Next Annotation:
Get TypeOf Previous Annotation:
This is how you can use the methods:
I hope this help you as it did me.
p.s. This code was mostly given to me by the Telerik support team via a ticket that I sent.
.
Get TypeOf Next Annotation:
public static AnnotationRangeMarkerBase GetNextAnnotationMarker(this RadDocument document){ if (!document.Selection.IsEmpty) { document.CaretPosition.MoveToPosition(document.Selection.Ranges.Last.EndPosition); } InlineLayoutBox inlineLayoutBox = document.CaretPosition.GetCurrentInlineBox(); while (inlineLayoutBox != null && !(inlineLayoutBox.AssociatedInline is AnnotationRangeMarkerBase)) { inlineLayoutBox = (InlineLayoutBox)DocumentStructureCollection.GetNextElementOfType(inlineLayoutBox, typeof(AnnotationMarkerLayoutBox)); } if (inlineLayoutBox == null) { return null; } AnnotationRangeMarkerBase annotationMarker = inlineLayoutBox.AssociatedInline as AnnotationRangeMarkerBase; if (annotationMarker == null) { return null; } return annotationMarker;}Get TypeOf Previous Annotation:
public static AnnotationRangeMarkerBase GetPreviousAnnotationMarker(this RadDocument document){ if (!document.Selection.IsEmpty) { document.CaretPosition.MoveToPosition(document.Selection.Ranges.Last.StartPosition); } InlineLayoutBox inlineLayoutBox = document.CaretPosition.GetCurrentInlineBox(); do { inlineLayoutBox = (InlineLayoutBox)DocumentStructureCollection.GetPreviousElementOfType(inlineLayoutBox, typeof(AnnotationMarkerLayoutBox)); } while (inlineLayoutBox != null && !(inlineLayoutBox.AssociatedInline is AnnotationRangeStart)); if (inlineLayoutBox == null) { return null; } return inlineLayoutBox.AssociatedInline as AnnotationRangeMarkerBase;}This is how you can use the methods:
//Get the previous annotation typeAnnotationRangeMarkerBase previousAnnotationType = RadDocumentExtensions.GetPreviousAnnotationMarker(radRichTextBox.Document);//Get the next annotation typeAnnotationRangeMarkerBase nextAnnotationType = RadDocumentExtensions.GetNextAnnotationMarker(radRichTextBox.Document);I hope this help you as it did me.
p.s. This code was mostly given to me by the Telerik support team via a ticket that I sent.