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

    Hello!

    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
    Admin
    Petya avatar
    975 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.Document.CaretPosition.MoveToLastPositionInDocument();
         RtfBox.InsertField(new DocumentVariableField() { VariableName = "Name" }, FieldDisplayMode.Code);

    I hope this helps.

    Regards,
    Petya
    Telerik
     
    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. UI for WPF is Visual Studio 2017 Ready
Back to Top