# Section Class

> 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.

- **Product:** TX Text Control .NET Server
- **Section:** Reference
- **Kind:** Class
- **Introduced:** 14.0
- **Namespace:** `TXTextControl`
- **Package:** `TXTextControl.TextControl.Core.SDK` (assembly `TXTextControl.Core.dll`, from the private NuGet feed or Text Control Offline Packages)
- **Package:** `TXTextControl.TextControl.ASP.SDK` (assembly `TXTextControl.dll`, from the private NuGet feed or Text Control Offline Packages)
- **.NET Framework:** reference `TXTextControl.dll` from the setup
- **Path:** TX Text Control .NET Server > Reference > TXTextControl > Section Class
- **1373 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/section/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/section/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/section/llms-full.txt

---

### 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](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/sections-property/llms-full.txt) property.

### Syntax

```csharp
public class Section
```

```vbnet
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:

```csharp
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;
```

```vbnet
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
Dim 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.

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

```vbnet
Dim section As Section = textControl.Sections(1)
Console.WriteLine("Section is ready for use.")
```

---

## In This Section

- [Section.Format Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/section/format-property/llms-full.txt): Gets 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.
- [Section.HeadersAndFooters Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/section/headersandfooters-property/llms-full.txt): Gets a collection of all headers and footers of the section. The property's value is an object of the type HeaderFooterCollection.
- [Section.Length Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/section/length-property/llms-full.txt): Gets the number of characters in the section. The section break character is not included.
- [Section.Number Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/section/number-property/llms-full.txt): Gets the section's number. The first section has the number 1.
- [Section.Select Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/section/select-method/llms-full.txt): Selects the section. The section break characters bounding the section are not selected.
- [Section.Start Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/section/start-property/llms-full.txt): Gets the number (one-based) of the first character in the section.

---

## Nearby

- **Previous:** [SaveSettings.UserDefinedDocumentProperties Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/savesettings/userdefineddocumentproperties-property/llms-full.txt)
- **Next:** [Section.Format Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/section/format-property/llms-full.txt)
