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
Public NotInheritable Class DocumentTargetCollection
  Implements ICollection
  Implements IEnumerable

Examples

The following example shows how to use the TXTextControl.DocumentTargetCollection Class.

//create documentTragets
TXTextControl.DocumentTarget newTarget = new TXTextControl.DocumentTarget("Page1");
newTarget.ID = 1; 

//Add documentTargets to collection
if (textControl1.DocumentTargets.CanAdd)
{
    textControl1.DocumentTargets.Add(newTarget);
    textBox1.Text = "DocumentTarget Name: " + newTarget.Name  + " could be added" + Environment.NewLine +
                        "Id is: " + newTarget.ID + Environment.NewLine +   
                         "textControl1.DocumentTargets.Count is: " + textControl1.DocumentTargets.Count + Environment.NewLine + Environment.NewLine";

} else textBox1.Text("DocumentTarget Name: " + newTarget.Name + "could NOT be added" + Environment.NewLine + Environment.NewLine);
Dim newTarget As TXTextControl.DocumentTarget = New TXTextControl.DocumentTarget("Page1")
newTarget.ID = 1

If textControl1.DocumentTargets.CanAdd Then
    textControl1.DocumentTargets.Add(newTarget)
    textBox1.Text = "DocumentTarget Name: " & newTarget.Name & " could be added" + Environment.NewLine & "Id is: " + newTarget.ID + Environment.NewLine & "textControl1.DocumentTargets.Count is: " + textControl1.DocumentTargets.Count + Environment.NewLine + Environment.NewLine
        ";"
Else
    textBox1.Text("DocumentTarget Name: " & newTarget.Name & "could NOT be added" + Environment.NewLine + Environment.NewLine)
End If

Methods

Method Description
Add Inserts the specified target at the current text input position.
Clear Removes all document targets from a Text Control document.
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 particular document target from the collection.
GetItems Gets all document targets at the current text input position.
Remove Removes the specified target from a Text Control document.

Properties

Property Description
CanAdd Gets a value indicating whether a new document target can be inserted at the current text input position.
Count Gets the number of elements contained in the collection.
IsSynchronized Returns true if the collection is designed to be thread safe, otherwise, it returns false.
Item Gets the field with the specified number from the collection.
SyncRoot Gets an object that can be used to synchronize access to the collection.