Back to Devexpress

Document.Sections Property

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-document-ce40e3a7.md

latest7.4 KB
Original Source

Document.Sections Property

Provides access to a collection of sections.

Namespace : DevExpress.XtraRichEdit.API.Native

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

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
SectionCollection Sections { get; }
vb
ReadOnly Property Sections As SectionCollection

Property Value

TypeDescription
SectionCollection

A SectionCollection interface defining a list of sections.

|

Example

The following code sample specifies page layout settings for the first section of the document: the A6 paper in landscape orientation with the left margin set to two inches.

View Example

csharp
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;
using DevExpress.Drawing.Printing;
using DevExpress.Utils;

using (var wordProcessor = new RichEditDocumentServer()) {

    wordProcessor.LoadDocument("Documents\\Grimm.docx");
    Document document = wordProcessor.Document;

    document.Sections[0].Page.PaperKind = DXPaperKind.A6;
    document.Sections[0].Page.Landscape = true;
    document.Sections[0].Margins.Left = Units.InchesToDocumentsF(2.0f);
}
vb
Imports DevExpress.XtraRichEdit
Imports DevExpress.XtraRichEdit.API.Native
Imports DevExpress.Drawing.Printing
Imports DevExpress.Utils

Using wordProcessor = New RichEditDocumentServer()
    wordProcessor.LoadDocument("Documents\Grimm.docx")
    Dim document As Document = wordProcessor.Document

    document.Sections(0).Page.PaperKind = DXPaperKind.A6
    document.Sections(0).Page.Landscape = True
    document.Sections(0).Margins.Left = Units.InchesToDocumentsF(2.0F)
End Using

The following code snippets (auto-collected from DevExpress Examples) contain references to the Sections property.

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.

winforms-richedit-document-api/CS/RichEditAPISample/CodeExamples/PageLayout.cs#L12

csharp
document.Unit = DevExpress.Office.DocumentUnit.Inch;
Section sec = document.Sections[0];
sec.LineNumbering.CountBy = 2;

wpf-richedit-document-api/CS/DXRichEditControlAPISample/CodeExamples/HeaderAndFooterActions.cs#L15

csharp
#region #CreateHeader
Section firstSection = document.Sections[0];
// Create an empty header.

word-document-api-examples/CS/CodeExamples/HeaderAndFooterActions.cs#L19

csharp
// Access the first document section.
Section firstSection = document.Sections[0];

word-processing-merge-documents-with-different-headers-and-footers/CS/Helpers/SectionsMerger.cs#L13

csharp
for (int i = 0; i < sourceSectionCount; i++) {
    Section sourceSection = source.Sections[i];
    Section targetSection = target.Sections[lastSectionIndexBeforeAppending + i];

how-to-add-a-watermark-to-the-document/CS/Form1.cs#L19

csharp
private void btnTextWatermark_Click(object sender, EventArgs e) {
    Section section = richEditControl1.Document.Sections[0];
    TextWatermarkOptions options = new TextWatermarkOptions()

winforms-richedit-document-api/VB/RichEditAPISample/CodeExamples/PageLayout.vb#L11

vb
document.Unit = DevExpress.Office.DocumentUnit.Inch
Dim sec As DevExpress.XtraRichEdit.API.Native.Section = document.Sections(0)
sec.LineNumbering.CountBy = 2

wpf-richedit-document-api/VB/DXRichEditControlAPISample/CodeExamples/PageLayoutActions.vb#L9

vb
document.Unit = DevExpress.Office.DocumentUnit.Inch
Dim sec As Section = document.Sections(0)
sec.LineNumbering.CountBy = 2

word-document-api-examples/VB/CodeExamples/HeaderAndFooterActions.vb#L18

vb
' Access the first document section.
Dim firstSection As DevExpress.XtraRichEdit.API.Native.Section = document.Sections(0)
' Check whether the document already has a header (the same header for all pages).

word-processing-merge-documents-with-different-headers-and-footers/VB/Helpers/SectionsMerger.vb#L14

vb
For i As Integer = 0 To sourceSectionCount - 1
    Dim sourceSection As Section = source.Sections(i)
    Dim targetSection As Section = target.Sections(lastSectionIndexBeforeAppending + i)

how-to-add-a-watermark-to-the-document/VB/Form1.vb#L21

vb
Private Sub btnTextWatermark_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnTextWatermark.Click
    Dim section As Section = richEditControl1.Document.Sections(0)
    Dim options As TextWatermarkOptions = New TextWatermarkOptions() With {

See Also

InsertSection(DocumentPosition)

Document Interface

Document Members

DevExpress.XtraRichEdit.API.Native Namespace