Back to Devexpress

ParagraphBorder Interface

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-388a37a2.md

latest4.6 KB
Original Source

ParagraphBorder Interface

Implements members used to specify paragraph border parameters.

Namespace : DevExpress.XtraRichEdit.API.Native

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

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
[ComVisible(true)]
public interface ParagraphBorder
vb
<ComVisible(True)>
Public Interface ParagraphBorder

The following members return ParagraphBorder objects:

Example

The following code snippet sets borders for multiple paragraphs:

csharp
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;
using System.Drawing;

using (var wordProcessor = new RichEditDocumentServer()) {
    Document document = wordProcessor.Document;

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

    // Append text to the document.
    document.AppendText(String.Format("Modified Paragraph" + 
        Environment.NewLine + "Normal" + Environment.NewLine + "Normal"));

    // Finalize the edit operation.
    document.EndUpdate();

    // Obtain a range from the first to the last paragraph
    Paragraph firstParagraph = document.Paragraphs[0];
    Paragraph thirdParagraph = document.Paragraphs[2];
    DocumentRange paragraphRange = 
        document.CreateRange(firstParagraph.Range.Start, thirdParagraph.Range.End.ToInt() - firstParagraph.Range.Start.ToInt());

    // Start to edit the paragraph.
    ParagraphProperties pp = document.BeginUpdateParagraphs(paragraphRange);
    SetBorder(pp.Borders.HorizontalBorder);
    SetBorder(pp.Borders.BottomBorder);
    SetBorder(pp.Borders.TopBorder);
    SetBorder(pp.Borders.LeftBorder);
    SetBorder(pp.Borders.RightBorder);

    // Finalize the edit operation.
    document.EndUpdateParagraphs(pp);
}

    static void SetBorder(ParagraphBorder border)
    {
        border.LineWidth = 2f;
        border.LineStyle = BorderLineStyle.Thick;
        border.LineColor = Color.SteelBlue;
    }
vb
Imports Microsoft.VisualBasic
Imports DevExpress.XtraRichEdit
Imports DevExpress.XtraRichEdit.API.Native
Imports System.Drawing

Using wordProcessor = New RichEditDocumentServer()
    Dim document As Document = wordProcessor.Document

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

    ' Append text to the document.
    document.AppendText(String.Format("Modified Paragraph" & Environment.NewLine & "Normal" & Environment.NewLine & "Normal"))
    ' Finalize the edit operation.
    document.EndUpdate()

    ' Obtain the range from the first to the last paragraph
    Dim firstParagraph As Paragraph = document.Paragraphs(0)
    Dim thirdParagraph As Paragraph = document.Paragraphs(2)
    Dim paragraphRange As DocumentRange = document.CreateRange(first.Range.Start, third.Range.End.ToInt() - firstParagraph.Range.Start.ToInt())

    ' Start to edit the paragraph.
    Dim pp As ParagraphProperties = document.BeginUpdateParagraphs(paragraphRange)
    SetBorder(pp.Borders.HorizontalBorder)
    SetBorder(pp.Borders.BottomBorder)
    SetBorder(pp.Borders.TopBorder)
    SetBorder(pp.Borders.LeftBorder)
    SetBorder(pp.Borders.RightBorder)

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

Shared Sub SetBorder(ByVal border As ParagraphBorder)
    border.LineWidth = 2F
    border.LineStyle = BorderLineStyle.Thick
    border.LineColor = Color.SteelBlue
End Sub

See Also

ParagraphBorder Members

DevExpress.XtraRichEdit.API.Native Namespace