# MainText Class

> The MainText class represents the main text of a TX Text Control document. A TX Text Control document consists of the main text, and additionally other pieces of text such as text frames and headers or footers. The MainText class implements the IFormattedText interface. Differently from the TextControl or WPF.TextControl classes the MainText object's collections of the IFormattedText interface do not depend on the input focus. For example, the TextControl.Tables collection contains the tables of the main text, if the main text has the input focus, but it contains the tables of the text frame, if a text frame has the input focus. The MainText.Tables collection always contains the tables of the main text regardless of the input focus.

- **Product:** TX Text Control .NET Server
- **Section:** Reference
- **Kind:** Class
- **Introduced:** 16.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
- **Inherits:** `TXTextControl.TextPartBase`
- **Implements:** `TXTextControl.IFormattedText`
- **Path:** TX Text Control .NET Server > Reference > TXTextControl > MainText Class
- **749 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/maintext/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/maintext/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/maintext/llms-full.txt

---

### Description

The MainText class represents the main text of a TX Text Control document. A TX Text Control document consists of the main text, and additionally other pieces of text such as text frames and headers or footers. The MainText class implements the [IFormattedText](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/iformattedtext/llms-full.txt) interface. Differently from the [TextControl](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/llms-full.txt) or [WPF.TextControl](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/llms-full.txt) classes the MainText object's collections of the [IFormattedText](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/iformattedtext/llms-full.txt) interface do not depend on the input focus. For example, the [TextControl.Tables](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/tables-property/llms-full.txt) collection contains the tables of the main text, if the main text has the input focus, but it contains the tables of the text frame, if a text frame has the input focus. The [MainText.Tables](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/iformattedtext/tables-property/llms-full.txt) collection always contains the tables of the main text regardless of the input focus.

### Syntax

```csharp
public class MainText : TextPartBase, IFormattedText
```

```vbnet
Public Class MainText
    Inherits TextPartBase
    Implements IFormattedText
```

### Examples

The following example applies bold formatting through the main text's selection.

```csharp
Selection formattedSelection = mainText.Selection;
formattedSelection.Bold = true;
mainText.Selection = formattedSelection;
```

```vbnet
Dim formattedSelection As Selection = mainText.Selection
formattedSelection.Bold = True
mainText.Selection = formattedSelection
```

---

## In This Section

- [MainText.Charts Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/maintext/charts-property/llms-full.txt): Gets a collection of all charts contained in the main text of the document. The property value is an object of the type DataVisualization.ChartCollection. The collection can be used to get or to alter a chart's attributes and to add charts to or to remove charts.
- [MainText.TextFrames Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/maintext/textframes-property/llms-full.txt): Gets a collection of all text frames contained in the main text of the document. The property value is an object of the type TextFrameCollection.

---

## Nearby

- **Previous:** [LoadSettings.UserDefinedDocumentProperties Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/loadsettings/userdefineddocumentproperties-property/llms-full.txt)
- **Next:** [MainText.Charts Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/maintext/charts-property/llms-full.txt)
