GetItem Method
- Namespace
TXTextControl
- Package
TXTextControl.asTextControl. WinForms. SDK TXTextControl.from the private NuGet feed or Text Control Offline Packagesdll
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();Public Function GetItem() As DocumentTargetGetItem(int)
Gets the document target with the specified id, previously set with the DocumentTarget.ID property.
public DocumentTarget GetItem(int id);Public Function GetItem(id As Integer) As DocumentTarget| Parameter | Description |
|---|---|
| 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);Public Function GetItem(targetName As String) As DocumentTarget| Parameter | Description |
|---|---|
| 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();textControl.Text = "Customer: Contoso Ltd."
textControl.Select(10, 12)
Dim documentTargetCollection As DocumentTargetCollection = textControl.DocumentTargets
documentTargetCollection.Add(New DocumentTarget("CustomerDetails") With { .ID = 100 })
Dim result As DocumentTarget = documentTargetCollection.GetItem(100)
If result IsNot Nothing Then result.ScrollTo()