Back to Devexpress

How to Add New Text

vcl-176002-expressricheditcontrol-how-to-add-new-text.md

latest1.3 KB
Original Source

How to Add New Text

  • Dec 28, 2020

This topic explains how to add new text to the document programmatically.

You can insert and append both RTF-formatted and unformatted text to the main document body, headers, footers, and text boxes via the Rich Edit control’s public API. Refer to the following code example:

delphi
var
  ADocument: IdxRichEditDocument;
begin
  ADocument := dxRichEditControl1.Document;
  ADocument.BeginUpdate; // You can include multipe append and/or insert text operations between the BeginUpdate and EndUpdate procedure calls
  ADocument.AppendText('The quick brown fox jumps over the lazy dog.');
  ADocument.EndUpdate;
end;

To append an RTF-formatted string and apply the document formatting to it, call the AppendRtfText function instead of AppendText. As in the previous case, you can pass the returned document range as a subdocument’s BeginUpdateCharacter function argument to modify character properties as required.