TX Text Control .NET for Windows Forms

GetItem Method

Method
Namespace
TXTextControl
Package
TXTextControl.TextControl.WinForms.SDK as TXTextControl.dll from the private NuGet feed or Text Control Offline Packages

Description

Gets a particular document target from the collection.

Syntax

GetItem()

Gets the first document target at the current text input position or null if there is no document target. This method is for compatibility only with prior versions. Use GetItems to get all targets at the current text input position.

public DocumentTarget GetItem();

GetItem(int)

Gets the document target with the specified id, previously set with the DocumentTarget.ID property.

public DocumentTarget GetItem(int id);
ParameterDescription
id

Specifies the document target's identifier. The method returns null, if a document target with the specified identifier does not exist. If there are more than target with this id in the document, the first target in the document's text is returned.

GetItem(string)

Gets the document target with the specified target name, previously set with the DocumentTarget.TargetName property.

public DocumentTarget GetItem(string targetName);
ParameterDescription
targetName

Specifies the document target's target name. The method returns null, if a document target with this target name does not exist. If there are more than target with this name in the document, the first target in the document's text is returned.

Examples

The following example works with document targets in the current document by using DocumentTargetCollection.GetItem.

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

DocumentTarget result = documentTargetCollection.GetItem(100);
result?.ScrollTo();