TX Text Control .NET for Windows Forms

DocumentTargetCollection Class

Class
Namespace
TXTextControl
Package
TXTextControl.TextControl.WinForms.SDK from the private NuGet feed or Text Control Offline Packages
Assembly
TXTextControl.dll
Install
dotnet add package TXTextControl.TextControl.WinForms.SDK .NET 8 and later. For .NET Framework, reference TXTextControl.dll from the setup.
Implements
ICollection, IEnumerable

Description

An instance of the DocumentTargetCollection class contains all targets in a Text Control document represented through objects of the type DocumentTarget. An instance of this class can only be obtained with the TextControl.DocumentTargets property. The DocumentTargetCollection class implements the IEnumerable and the ICollection interface. For more information see the technical article Text Fields and Hypertext Links.

Syntax

public sealed class DocumentTargetCollection : ICollection, IEnumerable

Examples

The following example works with document targets in the current document.

textControl.Text = "Customer: Contoso Ltd.";
textControl.Select(10, 12);
DocumentTargetCollection documentTargetCollection = textControl.DocumentTargets;
documentTargetCollection.Add(new DocumentTarget("CustomerDetails") { ID = 100 });

Members

Properties

PropertyDescription
CanAddGets a value indicating whether a new document target can be inserted at the current text input position. It is true if a target can be inserted, otherwise it is false.
CountGets the number of elements contained in the collection.
IsSynchronizedReturns true if the collection is designed to be thread safe, otherwise, it returns false.
ItemGets the field with the specified number from the collection. The number must be between 1 and Count. In C# this property is the indexer for the DocumentTargetCollection class.
SyncRootGets an object that can be used to synchronize access to the collection.

Methods

MethodDescription
AddInserts the specified target at the current text input position.
ClearRemoves all document targets from a Text Control document.
CopyToCopies the elements of the collection to an array, starting at a particular index.
GetEnumeratorReturns an enumerator that can be used to iterate through the collection.
GetItemGets a particular document target from the collection.
GetItemsGets all document targets at the current text input position. The method returns null, if there is no target at the current input position.
RemoveRemoves the specified target from a Text Control document.