
An instance of the TextPartCollection class contains all text parts in a TX Text Control document. A text part can either be the document's main text, a text frame or a header or footer. A text frame is represented through a TextFrame object, a header or footer through a HeaderFooter object and the document's main text is represented through a MainText object. A TextPartCollection object contains all these objects in a geometric order. The first object in the collection is the main text, followed by all text frames in geometric order. At the end of the collection all headers and footers are contained also geometrically ordered. All objects in a text part collection implement the IFormattedText interface. The collection can be obtained with the TextControl.TextParts, WPF.TextControl.TextParts or ServerTextControl.TextParts property. The TextPartCollection class implements the IEnumerable and the ICollection interfaces.
Introduced: 16.0.
[C#]
public class TextPartCollection : ICollection, IEnumerable
[Visual Basic]
Public Class TextPartCollection
Implements ICollection
Implements IEnumerable
| Property | Description | |
| Count | Gets the number of elements contained in the collection. |
| Method | Description | |
| Activate | Sets the input focus to the specified text part. | |
| CopyTo | Copies the elements of the collection to an array, starting at a particular index. | |
| GetEnumerator | Returns an enumerator that can be used to iterate through the collection. | |
| GetItem | Gets the activated text part from the collection, which is the text part with the input focus. | |
| GetMainText | Gets the main text part of the document. |
The following example shows how to loop through all text parts a get the first line of each part.
[C#]
foreach (object obj in textControl1.TextParts)
{
Console.WriteLine("First Line: " + ((IFormattedText)obj).Lines[1].Text);
}