TextPartCollection Class
- Namespace
TXTextControl
- Package
TXTextControl.from the private NuGet feed or Text Control Offline PackagesTextControl. WPF. SDK
- Assembly
TXTextControl.dll
- Install
dotnet add package TXTextControl..NET 8 and later. For .NET Framework, referenceTextControl. WPF. SDK TXTextControl.from the setup.dll
- Implements
- ICollection, IEnumerable
Description
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, IEnumerablePublic Class TextPartCollection
Implements ICollection, IEnumerableExamples
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)
NextThe following example works with text parts in the current document. The created object is then available to the surrounding document workflow.
TextPartCollection textPartCollection = textControl.TextParts;
Console.WriteLine("Text Part Collection is ready for use.");Dim textPartCollection As TextPartCollection = textControl.TextParts
Console.WriteLine("Text Part Collection is ready for use.")Members
Properties
| Property | Description |
|---|---|
| Count | Gets the number of elements contained in the collection. |
Methods
| Method | Description |
|---|---|
| Activate | Sets the input focus to the specified text part. If the activated text part is not in the visible part of the document, the document is scrolled. |
| 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. |