Back to Devexpress

Paragraph Class

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-4edb2252.md

latest4.5 KB
Original Source

Paragraph Class

A document paragraph.

Namespace : DevExpress.XtraRichEdit.API.Native

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

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
[ComVisible(true)]
public abstract class Paragraph
vb
<ComVisible(True)>
Public MustInherit Class Paragraph

The following members return Paragraph objects:

Remarks

Access Paragraphs

The ParagraphCollection contains all document paragraphs. Use the SubDocument.Paragraphs property to access a specific paragraph by its index. The Section.Paragraphs property obtains a collection of paragraphs in a specific document section. Call the ReadOnlyParagraphCollection.Get method to retrieve a paragraph related to a specific range.

Format Paragraphs

Yoy can format paragraphs directly or use document styles. Refer to the following topic for more examples on how to format paragraphs:

Read Tutorial: Text Formatting

Example

The following snippet appends a paragraph and inserts a paragraph at the start of the second section:

csharp
using DevExpress.XtraRichEdit.API.Native;

using (var wordProcessor = new RichEditDocumentServer())
{
  wordProcessor.LoadDocument("FirstLook.docx");
  Document document = wordProcessor.Document;

  // Start the document update:
  document.BeginUpdate();

  // Append a paragraph:
  Paragraph appendedParagraph = document.Paragraphs.Append();
  document.InsertText(appendedParagraph.Range.Start, "Appended paragraph");

  // Insert a paragraph at the start of the second section:
  Paragraph paragraph =
     document.Paragraphs.Insert(document.Sections[1].Range.Start);
  DocumentPosition position =
     document.Paragraphs[paragraph.Index - 1].Range.Start;
  document.InsertText(position, "Inserted paragraph");

  // Finalize the document update:
  document.EndUpdate();
}
vb
Imports DevExpress.XtraRichEdit.API.Native

Using wordProcessor = New RichEditDocumentServer()
  wordProcessor.LoadDocument("FirstLook.docx")
  Dim document As Document = wordProcessor.Document

  ' Start the document update:
  document.BeginUpdate()

  ' Append a paragraph:
  Dim appendedParagraph As Paragraph = document.Paragraphs.Append()
  document.InsertText(appendedParagraph.Range.Start, "Appended paragraph")

  ' Insert a paragraph at the start of the second section:
  Dim paragraph As Paragraph =
     document.Paragraphs.Insert(document.Sections(1).Range.Start)
  Dim position As DocumentPosition =
     document.Paragraphs(paragraph.Index - 1).Range.Start
  document.InsertText(position, "Inserted paragraph")

  ' Finalize the document update:
  document.EndUpdate()

Inheritance

Object Paragraph

See Also

Paragraph Members

Paragraphs in Word Documents

DevExpress.XtraRichEdit.API.Native Namespace