TX Text Control .NET for Windows Forms

SubTextPart Constructor

Constructor|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

Initializes a new instance of the SubTextPart class.

Syntax

SubTextPart(string, int)

Creates a subtextpart with the specified name and/or id. The start and length of the subtextpart are initialized to zero. When a zero-length subtextpart is inserted, the current text selection defines it position and length.

public SubTextPart(string name, int id);
ParameterDescription
name

Specifies the name of the subtextpart. This parameter can be null or an empty string to indicate, that the subtextpart has no name.

id

Specifies an identifier for the subtextpart. This parameter can be 0 to indicate, that the subtextpart has no identifier.

SubTextPart(string, int, int, int)

Creates a subtextpart with the specified name, id, start position and length.

public SubTextPart(string name, int id, int start, int length);
ParameterDescription
name

Specifies the name of the subtextpart. This parameter can be null or an empty string to indicate, that the subtextpart has no name.

id

Specifies an identifier for the subtextpart. This parameter can be 0 to indicate, that the subtextpart has no identifier.

start

Specifies the index (one-based) of the first character which belongs to the subtextpart.

length

Specifies the number of characters which belong to the subtextpart.

Examples

The following example marks the selected customer name as a named document region.

textControl.Text = "Customer: Contoso Ltd.";
textControl.Select(10, 12);
SubTextPart subTextPart = new("CustomerName", 10);
textControl.SubTextParts.Add(subTextPart);