Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Append Text to the Paragraph

The following code snippet appends text to the end of the last paragraph.

result

View Example

using DevExpress.XtraRichEdit.API.Native;
using System.Linq;

using (var wordProcessor = new RichEditDocumentServer())
{
  // Access a document.
  Document document = wordProcessor.Document;

  // Start to edit the document.
  document.BeginUpdate();

  // Append text
  document.AppendText("First Paragraph\nSecond Paragraph\nThird Paragraph");

  // Obtain the last paragraph's end position.
  DocumentPosition paragraphEnd = document.Paragraphs.Last().Range.End;

  // Insert text to the paragraph end.
  document.InsertText(paragraphEnd, "<<Appended to Paragraph End>>");

  // Finalize to edit the document.
  document.EndUpdate();
}