Back to Devexpress

ParagraphProperties Interface

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-64ce2065.md

latest5.7 KB
Original Source

ParagraphProperties Interface

Contains paragraph properties.

Namespace : DevExpress.XtraRichEdit.API.Native

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

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
[ComVisible(true)]
public interface ParagraphProperties :
    ParagraphPropertiesWithTabs,
    ParagraphPropertiesBase
vb
<ComVisible(True)>
Public Interface ParagraphProperties
    Inherits ParagraphPropertiesWithTabs,
             ParagraphPropertiesBase

The following members return ParagraphProperties objects:

Remarks

To modify a paragraph which encompasses the specified range, use the SubDocument.BeginUpdateParagraphsSubDocument.EndUpdateParagraphs paired methods.

Example

The following code snippet changes paragraph formatting in code:

csharp
using DevExpress.XtraRichEdit.API.Native;
using DevExpress.Office.Utils;

using (var wordProcessor = new RicheditDocumentServer())
{
    // Access a document.
    Document document = wordProcessor.Document;

    // Start to edit the document.
    document.BeginUpdate();

    // Append text to the document.
    document.AppendText("Modified Paragraph\nNormal\nNormal");

    // Finalize document modification.
    document.EndUpdate();

    // Access the first paragraph's range
    DocumentRange range = document.Paragraphs[0].Range;

    // Start to edit the paragraph.
    ParagraphProperties pp = document.BeginUpdateParagraphs(range);

    // Specify the paragraph's alignment.
    pp.Alignment = ParagraphAlignment.Center;

    // Specify the paragraph's line spacing.
    pp.LineSpacingType = ParagraphLineSpacing.Multiple;
    pp.LineSpacingMultiplier = 3;

    // Set the paragraph's left indent to 0.5 document unit.
    // Default unit is 1/300 of an inch (a document unit).
    pp.LeftIndent = Units.InchesToDocumentsF(0.5f);

    // Start to modify tab stops in the paragraph.
    TabInfoCollection tbiColl = pp.BeginUpdateTabs(true);

    // Create a new tab stop for the paragraph.
    TabInfo tbi = TabInfo();

    // Specify the tab stop's alignment type.
    tbi.Alignment = TabAlignmentType.Center;

    // Set the tab stop position to 1.5 document unit.
    tbi.Position = Units.InchesToDocumentsF(1.5f);

    // Add the tab stop to the collection of tab stops.
    tbiColl.Add(tbi);

    // Finalize tab stop modification.
    pp.EndUpdateTabs(tbiColl);

    // Finalize the paragraph edit operation.
    document.EndUpdateParagraphs(pp);
}
vb
Imports Microsoft.VisualBasic
Imports DevExpress.XtraRichEdit.API.Native
Imports DevExpress.Office.Utils

Using wordProcessor = New RicheditDocumentServer()
    ' Access a document.
    Dim document As Document = wordProcessor.Document

    ' Start to edit the document.
    document.BeginUpdate()

    ' Append text to the document.
    document.AppendText("Modified Paragraph\nNormal\nNormal")

    ' Finalize document modification.
    document.EndUpdate()

    ' Access the first paragraph range
    Dim range As DocumentRange = document.Paragraphs(0).Range

    ' Start to edit the paragraph.
    Dim pp As ParagraphProperties = document.BeginUpdateParagraphs(range)

    ' Specify the paragraph's alignment.
    pp.Alignment = ParagraphAlignment.Center

    ' Specify the paragraph's line spacing.
    pp.LineSpacingType = ParagraphLineSpacing.Multiple
    pp.LineSpacingMultiplier = 3

    ' Set the paragraph's left indent to 0.5 document unit.
    ' Default unit is 1/300 of an inch (a document unit).
    pp.LeftIndent =.Units.InchesToDocumentsF(0.5F)

    ' Start to modify tab stops in the paragraph.
    Dim tbiColl As TabInfoCollection = pp.BeginUpdateTabs(True)

    ' Create a new tab stop for the paragraph.
    Dim tbi As TabInfo = TabInfo()

    ' Specify the tab stop's alignment type.
    tbi.Alignment = TabAlignmentType.Center

    ' Set the tab stop position to 1.5 document unit.
    tbi.Position = Units.InchesToDocumentsF(1.5F)

    ' Add the tab stop to the collection of tab stops.
    tbiColl.Add(tbi)

    ' Finalize tab stop modification.
    pp.EndUpdateTabs(tbiColl)

    ' Finalize the paragraph edit operation.
    document.EndUpdateParagraphs(pp)
End Using

See Also

ParagraphProperties Members

BeginUpdateParagraphs(DocumentRange)

EndUpdateParagraphs(ParagraphProperties)

Paragraph

DevExpress.XtraRichEdit.API.Native Namespace