Re-Selection of text throws 'inline does not belong to this document'

7 posts, 0 answers
  1. Eric
    Eric avatar
    2 posts
    Member since:
    Dec 2011

    Posted 16 Feb 2012 Link to this post

    The original issue was that when the application was alt tabbed away from and then back to after they had copied text from somewhere else to paste where their cursor is in the radrichtextbox, the cursor moved.  The solution to this was to create 2 methods in the control that we have wrapped around the radrichtextbox, the first one is called at the beginning of the lost focus and the second one is 2 lines of code later after the text is pulled into the data context.  The cursor position works fine but it now loses selection when right clicking because right click fires lostfocus which resets the cursor position.  Here is the attempt to re-select the selection (assuming 1 text selection area).  The storing works but the re-setting blows up.

            private PointF _position;

            private DocumentPosition _start;

            private DocumentPosition _end;


            public void StoreCaretPosition()


                _position = rtArea.Document.CaretPosition.Location;

                if (rtArea.Document.Selection.Ranges.First != null)


                    _start = new DocumentPosition(rtArea.Document.Selection.Ranges.First.StartPosition);

                    _end = new DocumentPosition(rtArea.Document.Selection.Ranges.First.EndPosition);



            public void RestoreCaretPosition()






    The error we are getting is after adding the end selection it blows up on the method’s end curly bracket with the error ‘inline does not belong to this document.’

  2. Andrew
    Andrew avatar
    140 posts

    Posted 17 Feb 2012 Link to this post

    Hello Eric,

    We could not reproduce your issue. We would very much appreciate if you can send us a demo project demonstrating the unusual behavior with pressing alt+tab.
    On the other hand you can try saving the start and end position of the selection as PointF too.

    PointF _start = rtArea.Document.Selection.Ranges.First.StartPosition.Location;
    and then 
    DocumentPosition startDocumentPosition = new DocumentPosition(this.rtArea.Document);

    and one more thing. The right way to set selection programatically is to use SetSelectionStart method 
    (instead of AddSelectionStart) first and then AddSelectionEnd.

    Hope we helped in a way. Please get back to us, if you can't resolve your problem. Regards,
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. Eric
    Eric avatar
    2 posts
    Member since:
    Dec 2011

    Posted 17 Feb 2012 Link to this post

    Changing the code from 'Add' to 'Set' worked for me.  Thank you.
  4. Venkat
    Venkat avatar
    1 posts
    Member since:
    Nov 2008

    Posted 24 Sep 2012 Link to this post

    We are having One Silverlight Text Box and one Rich Text Box UI on my xaml page.

    Once I select  Text from the TextBox and then  I focused my Cursor on Teleric's Rich Text BOX ,then the selection from the Silverlight Text Box is loosing (Expected behavior).

    Once I select text from Teleric's Rich Text Box UI and then when I focus my cursor on Silverlight's Text Box , the selection from the Rich Text Box is not losing..! it still selected. when I have selected text from Silver light Text Box, then also the Rich Text Box text selection remains same. Now I am having two selections , this is not expected.If I press Ctl+C i am confused from which text box the text is copied to clip board.

    So my requirement is to un select the text selection on Rich Text box , when it looses focus,but when I do this, even when I click on Ribbon buttons, the selection is losing...! How can I achieve this.?

    Even if I write  logic to clear the selection of Rich Text Box on Text Box's got focus event , but I don't know after loosing the focus on Rich Text Box where the user points his cursor, so if my page has so many controls , then i need to add this logic to all controls, but this is not a good solution , i think.

    my Rad control version is 2011.1.149.1040.

  5. Iva Toteva
    Iva Toteva avatar
    1319 posts

    Posted 25 Sep 2012 Link to this post

    Hi Venkat,

    We have this item as a feature request, but it has not been implemented yet.

    You can use this PITS issue to vote for this feature and track our progress:
    You can follow the PITS Issue by its ID: 12759
    Public Url: 

    All the best,
    Iva Toteva
    the Telerik team

    Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

  6. danparker276
    danparker276 avatar
    389 posts
    Member since:
    Aug 2010

    Posted 30 Jul 2013 Link to this post

    I am also getting this error sometimes.  Is it safe to just replace all the AddSelectionStart with SetSelectionStart
  7. Iva Toteva
    Iva Toteva avatar
    1319 posts

    Posted 01 Aug 2013 Link to this post

    Hello Dan,

    Please refer to 
    this forum thread for a more elaborate explanation of the way the selection methods work in general and in particular in the way you seem to be using them.

    Iva Toteva
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top