GetItem Method
- Namespace
TXTextControl
- Package
TXTextControl.asTextControl. WPF. SDK TXTextControl.from the private NuGet feed or Text Control Offline Packagesdll
Description
Gets a particular subtextpart from the collection.
Syntax
GetItem()
Gets the subtextpart at the current text input position. If there is more than one textpart at the current input position the textpart with the highest level is returned.
public SubTextPart GetItem();Public Function GetItem() As SubTextPartGetItem(string)
Gets the subtextpart with the specified name. The method returns null, if such a textpart does not exist. If more than one textpart with this name exists, the first found textpart is returned.
public SubTextPart GetItem(string name);Public Function GetItem(name As String) As SubTextPart| Parameter | Description |
|---|---|
| name | Specifies the textpart's name set with the Name property. The method returns null if a textpart with the specified name does not exist. |
GetItem(int)
Gets the subtextpart with the specified id. The method returns null, if such a textpart does not exist. If more than one textpart with this id exists, the first found textpart is returned.
public SubTextPart GetItem(int id);Public Function GetItem(id As Integer) As SubTextPart| Parameter | Description |
|---|---|
| id | Specifies the textpart's identifier. The method returns null if a textpart with the specified identifier does not exist. |
Return Value
The return value is null, if a subtextpart with the specified parameters could not be found. Otherwise, it is an object of the type SubTextPart.
Examples
The following example retrieves a named document region and scrolls it into view.
textControl.Text = "Customer: Contoso Ltd.";
textControl.Select(10, 12);
SubTextPartCollection parts = textControl.SubTextParts;
SubTextPart customer = new("CustomerName", 10) { Data = @"{""category"":""customer""}" };
parts.Add(customer);
SubTextPart part = parts.GetItem(10);
part?.ScrollTo();textControl.Text = "Customer: Contoso Ltd."
textControl.Select(10, 12)
Dim parts As SubTextPartCollection = textControl.SubTextParts
Dim customer As New SubTextPart("CustomerName", 10) With { .Data = "{""category"":""customer""}" }
parts.Add(customer)
Dim part As SubTextPart = parts.GetItem(10)
If part IsNot Nothing Then part.ScrollTo()