.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
A newer version of this page is available. Switch to the current version.

Paragraph Class

Represents a single paragraph in a document.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v19.1.Core.dll


public abstract class Paragraph
Public MustInherit Class Paragraph


All paragraphs in a document are represented by the ParagraphCollection, accessible via the SubDocument.Paragraphs property. A document Section contains a collection of paragraphs and provides the Section.Paragraphs property to access it.

To modify formatting for a paragraph which encompasses the specified range, get a SubDocument interface for this range first. For this purpose, you can use the DocumentPosition.BeginUpdateDocument - DocumentPosition.EndUpdateDocument or the DocumentRange.BeginUpdateDocument - DocumentRange.EndUpdateDocument method pairs.

Then, use the SubDocument.BeginUpdateParagraphs - SubDocument.EndUpdateParagraphs paired methods. The SubDocument.BeginUpdateParagraphs method requires a DocumentRange as the parameter, and returns a ParagraphProperties interface which exposes formatting properties for this range.

To modify the text of the paragraph, you can use its SubDocument methods. For example, to append a text to the current paragraph, use the technique illustrated below.

The following code snippet appends text to the end of the current paragraph. Note that the DocumentPosition.BeginUpdateDocument call is required for proper operation within header/footer since it returns a SubDocument interface.

document.AppendText("First Paragraph" & vbLf & "Second Paragraph" & vbLf & "Third Paragraph")
Dim pos As DocumentPosition = document.CaretPosition
Dim doc As SubDocument = pos.BeginUpdateDocument()
Dim par As Paragraph = doc.Paragraphs.Get(pos)
Dim newPos As DocumentPosition = doc.CreatePosition(par.Range.End.ToInt() - 1)
doc.InsertText(newPos, "<<Appended to Paragraph End>>")


See Also