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, a footnote section or a header or footer. A text frame is represented through a TextFrame object, a header or footer through a HeaderFooter object, a footnote section through a FootnoteSection 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.

Syntax

public class TextPartCollection : ICollection, IEnumerable
Public Class TextPartCollection
  Implements ICollection
  Implements IEnumerable

Introduced: 16.0.

Examples

The following example shows how to loop through all text parts a get the first line of each part.

foreach (object obj in textControl1.TextParts)
{
    Console.WriteLine("First Line: " + ((IFormattedText)obj).Lines[1].Text);
}
For Each obj As Object In textControl1.TextParts
    Console.WriteLine("First Line: " + DirectCast(obj, IFormattedText).Lines(1).Text)
Next

Methods

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 a certain text part from the collection.
GetMainText Gets the main text part of the document.

Properties

Property Description
Count Gets the number of elements contained in the collection.

Further Reading

Learn more about the TXTextControl.TextPartCollection Class in the Text Control Blog: