This is a migrated thread and some comments may be shown as answers.

Inserting a new line

1 Answer 48 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Edward
Top achievements
Rank 1
Edward asked on 22 Jun 2012, 03:56 PM
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.

1 Answer, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 25 Jun 2012, 03:33 PM
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 >>

Tags
RichTextBox
Asked by
Edward
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Share this question
or