Back to Devexpress

How to: Insert Text at the Cursor Position

wpf-116731-controls-and-libraries-rich-text-editor-examples-text-how-to-insert-text-at-the-cursor-position.md

latest756 B
Original Source

How to: Insert Text at the Cursor Position

  • Jun 07, 2019

The following code snippet demonstrates how you can insert text at the cursor position in the RichEditControl document:

View Example

csharp
DocumentPosition pos = document.CaretPosition;
SubDocument doc = pos.BeginUpdateDocument();
doc.InsertText(pos, " INSERTED TEXT ");
pos.EndUpdateDocument(doc);
vb
Dim pos As DocumentPosition = document.CaretPosition
Dim doc As SubDocument = pos.BeginUpdateDocument()
doc.InsertText(pos, " INSERTED TEXT ")
pos.EndUpdateDocument(doc)