How to replace all inlineUIContainers in RadDocument by SpanBoxs

3 posts, 0 answers
  1. york
    york avatar
    160 posts
    Member since:
    Jul 2012

    Posted 20 Jan 2013 Link to this post

    I try to replace all inlineUIContainers in RadDocument by SpanBoxes. I know how to do it at caretposition using Delete as,
    DocumentPosition currentPosition = radRichTextBox1.Document.CaretPosition;
    radRichTextBox1.Document.Delete(false, currentPosition);

    However I am not sure how to get documentpostion for each inlineUIContainers. I need help on this.

  2. Christian
    Christian avatar
    1 posts
    Member since:
    Aug 2011

    Posted 14 Jun 2013 Link to this post

    Did you figure this out?
    I need help for the exact same problem...
  3. DevCraft R3 2016 release webinar banner
  4. Boby
    Boby avatar
    588 posts

    Posted 19 Jun 2013 Link to this post

    Hello Christian, York,
    You can achieve this as follows:
    foreach (var inlineUIContainer in this.radRichTextBox.Document.EnumerateChildrenOfType<InlineUIContainer>().Reverse().ToList())
        this.radRichTextBox.InsertInline(new Span("InlineUIContainer was here."));
    this.radRichTextBox.EndUndoGroup("Replace all InlineUIContainers");
    The trick is to iterate the document elements in reversed order to avoid invalidating of the internal document indexes.


    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top