Skip to main content
A newer version of this page is available. .

Paragraph Class

Represents a single paragraph in a document.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v18.2.Core.dll

Declaration

[ComVisible(true)]
public abstract class Paragraph

Remarks

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.BeginUpdate()
document.AppendText("First Paragraph" & vbLf & "Second Paragraph" & vbLf & "Third Paragraph")
document.EndUpdate()
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>>")
pos.EndUpdateDocument(doc)

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Paragraph class.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

Inheritance

Object
Paragraph
See Also