TX Text Control .NET for Windows Forms

GetItem Method

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

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();

GetItem(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);
ParameterDescription
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);
ParameterDescription
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();