DocumentVariables in imported doc

2 posts, 0 answers
  1. Sergey
    Sergey avatar
    58 posts
    Member since:
    Jan 2013

    Posted 08 Jul 2014 Link to this post


    I want to use variables in the middle of the imported rtf document.

    When I write:
    RtfBox.InsertField(new DocumentVariableField() { VariableName = "Name" }, FieldDisplayMode.Code);
    field appears at the beginning of the document.

    Is there any way to force field to appear at concrete place?

  2. Petya
    Petya avatar
    973 posts

    Posted 09 Jul 2014 Link to this post

    Hello Sergey,

    All of RadRichTextBox's Insert~() methods work with the caret position (or document selection if such is available). By default when you load a document the caret is located at the first position in the document which is most likely the cause of the behavior you are observing.

    The DocumentPosition class exposes a set of handy methods which allow you to move the caret programmatically. For example, the next code snippet would move the caret at the end of the document and allow you to insert content there.
         RtfBox.InsertField(new DocumentVariableField() { VariableName = "Name" }, FieldDisplayMode.Code);

    I hope this helps.

    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
  3. DevCraft R3 2016 release webinar banner
Back to Top