TX Text Control .NET Server

Section Class

Class|Introduced in 14.0
Namespace
TXTextControl
Package
TXTextControl.TextControl.Core.SDK from the private NuGet feed or Text Control Offline Packages
Assembly
TXTextControl.Core.dll
Install
dotnet add package TXTextControl.TextControl.Core.SDK .NET 8 and later. For .NET Framework, reference TXTextControl.dll from the setup.
Also in
TXTextControl.TextControl.ASP.SDK as TXTextControl.dll

Description

An object of the Section class represents a section of a document. Sections are numbered from the beginning to the end of the document beginning with 1. A document has at least one section. A section is a part of the document that specifies the page size, the page margins and the headers and footers. A section object can be obtained from the section collection available through the TextControl.Sections property.

Syntax

public class Section

Examples

The following example shows how to use the SectionClass to insert a new section with a different header and page orientation than the previous one:

textControl1.HeadersAndFooters.Add(TXTextControl.HeaderFooterType.Header);
textControl1.Sections.Add(TXTextControl.SectionBreakKind.BeginAtNewPage);
textControl1.Sections[2].Format.Landscape = true;
textControl1.Sections[2].HeadersAndFooters.GetItem(TXTextControl.HeaderFooterType.Header).ConnectedToPrevious = false;
TXTextControl.Selection mySelection = new TXTextControl.Selection(0, -1);
mySelection.Text = "New Section";
textControl1.Sections[2].HeadersAndFooters.GetItem(TXTextControl.HeaderFooterType.Header).Selection = mySelection;

The following example works with the first section of the current document. The created object is then available to the surrounding document workflow.

Section section = textControl.Sections[1];
Console.WriteLine("Section is ready for use.");

Members

Properties

PropertyDescription
FormatGets or sets the section's formatting attributes. The property's value is an object of the type SectionFormat which defines the page size and the page margins.
HeadersAndFootersGets a collection of all headers and footers of the section. The property's value is an object of the type HeaderFooterCollection.
LengthGets the number of characters in the section. The section break character is not included.
NumberGets the section's number. The first section has the number 1.
StartGets the number (one-based) of the first character in the section.

Methods

MethodDescription
SelectSelects the section. The section break characters bounding the section are not selected.

Further Reading

  • How to Remove All Section Breaks in a Document? –