Inserting a new line

2 posts, 0 answers
  1. Edward
    Edward avatar
    84 posts
    Member since:
    Feb 2011

    Posted 22 Jun 2012 Link to this post

    I am trying to insert some text that is like newtext = "Line 1 \r\n Line 2 \r\n" and so on.  I wrap the text with a span (Span xxx = new Span(newtext)) and then use the "Children.AddAfter" method to add it to the location I want to.

    However the formatting is all screwed up.  For text without line break then it is fine.

    I also try to replace \r\n with FormattingSymbolLayoutBox.LINE_BREAK but it didn't work.
  2. Iva Toteva
    Iva Toteva avatar
    1319 posts

    Posted 25 Jun 2012 Link to this post

    Hello Edward,

    It is not possible to have several new paragraphs in the text of a Span. This is due to the fact that Spans are inline elements and each span is a children of one paragraph.

    This article shows how you can add one paragraph to the document depending on whether the document has been measured and arranged or not. If you would like to insert some more complex piece into a document, you should create a document fragment and insert it in the place you would like it to appear.

    You can find more information on how to create a DocumentFragment in this forum post.

    All the best,
    Iva Toteva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top