# SubTextPartCollection Class

> Contains all subtextparts in the main text or another main part of a document. It is a collection of objects of the type SubTextPart. A collection object can be obtained with the TextControl.SubTextParts, the HeaderFooter.SubTextParts or the TextFrame.SubTextParts property. The SubTextPartCollection class implements the IEnumerable and the ICollection interfaces. The text of each main part of the document, which are the main text, a header or footer or a textframe, can be divided in further parts, called subtextparts. A subtextpart must be a selectable part of the document. It can immediately follow its previous textpart. The position between two textparts belongs to the following textpart. Subtextparts can be nested. A nested textpart must be smaller than its outer textpart. A nested textpart can start or end at the same position as its outer textpart, but a nested textpart cannot have the same length as its outer textpart. To insert a nested textpart its outer textpart must be inserted first. A textpart cannot have a length of zero. When the last character of a textpart is deleted, the textpart itself is also deleted.

- **Product:** TX Text Control .NET for Windows Forms
- **Section:** Reference
- **Kind:** Class
- **Introduced:** 23.0
- **Namespace:** `TXTextControl`
- **Package:** `TXTextControl.TextControl.WinForms.SDK` (assembly `TXTextControl.dll`, from the private NuGet feed or Text Control Offline Packages)
- **.NET Framework:** reference `TXTextControl.dll` from the setup
- **Implements:** `System.Collections.ICollection`, `System.Collections.IEnumerable`
- **Path:** TX Text Control .NET for Windows Forms > Reference > TXTextControl > SubTextPartCollection Class
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/subtextpartcollection/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/subtextpartcollection/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/subtextpartcollection/llms-full.txt

---

## On This Page

- [Description](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/subtextpartcollection/#description)
- [Syntax](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/subtextpartcollection/#syntax)
- [Examples](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/subtextpartcollection/#examples)
- [Members](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/subtextpartcollection/#members)

---

## In This Section

- [SubTextPartCollection.Add Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/subtextpartcollection/add-method/llms.txt): Adds a new subtextpart to the document. Its position is defined through the SubTextPart.Start and SubTextPart.Length properties. If the subtextpart's length is zero, the current text selection is used to define the position.
- [SubTextPartCollection.AddResult Enumeration](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/subtextpartcollection/addresult-enumeration/llms.txt): Specifies the result when a subtextpart has been added to the document.
- [SubTextPartCollection.CopyTo Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/subtextpartcollection/copyto-method/llms.txt): Copies the elements of the collection to an array, starting at a particular index.
- [SubTextPartCollection.Count Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/subtextpartcollection/count-property/llms.txt): Gets the number of elements contained in the collection.
- [SubTextPartCollection.GetEnumerator Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/subtextpartcollection/getenumerator-method/llms.txt): Returns an enumerator that can be used to iterate through the collection.
- [SubTextPartCollection.GetItem Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/subtextpartcollection/getitem-method/llms.txt): Gets a particular subtextpart from the collection.
- [SubTextPartCollection.IsSynchronized Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/subtextpartcollection/issynchronized-property/llms.txt): Returns true if the collection is designed to be thread safe, otherwise, it returns false.
- [SubTextPartCollection.Item Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/subtextpartcollection/item-property/llms.txt): Gets the subtextpart with the specified number from the collection. The number must be between 1 and Count. In C# this property is the indexer for the SubTextPartCollection class.
- [SubTextPartCollection.Remove Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/subtextpartcollection/remove-method/llms.txt): Removes a subtextpart from the collection including all its nested subtextparts.
- [SubTextPartCollection.SyncRoot Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/subtextpartcollection/syncroot-property/llms.txt): Gets an object that can be used to synchronize access to the collection.

---

## Nearby

- **Previous:** [SubTextPart.Text Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/subtextpart/text-property/llms.txt)
- **Next:** [SubTextPartCollection.Add Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/subtextpartcollection/add-method/llms.txt)
