Get Field in CaretPosition

2 posts, 0 answers
  1. William
    William avatar
    6 posts
    Member since:
    Mar 2015

    Posted 04 Apr 2015 Link to this post


    How can I get a reference to a field that is at the current CaretPosition ?

    Thanks in advance.

  2. Tanya
    Tanya avatar
    577 posts

    Posted 07 Apr 2015 Link to this post

    Hi William,

    The Fields can be interpreted as an Annotations, as their FieldRangeStart/FieldRangeEnd derive respectively from AnnotationRangeStart/AnnotationRangeEnd. You could get the current inline using the CaretPosition's GetCurretnInline method and obtain the annotation ranges which surround it with GetContainingAnnotationRanges<TRangeStart>():
    Inline inline = this.radRichTextBox.Document.CaretPosition.GetCurrentInline();
    IEnumerable<AnnotationRangeStart> ranges = this.radRichTextBox.Document.GetContainingAnnotationRanges<FieldRangeStart>(inline);

    More information about how to work with Annotations can be found in the Manipulating Annotations article in our documentation.


    See What's Next in App Development. Register for TelerikNEXT.

Back to Top