TX Text Control .NET Server

SubTextPart Class

Class|Introduced in 23.0
Namespace
TXTextControl
Package
TXTextControl.TextControl.Core.SDK from the private NuGet feed or Text Control Offline Packages
Assembly
TXTextControl.Core.dll
Install
dotnet add package TXTextControl.TextControl.Core.SDK .NET 8 and later. For .NET Framework, reference TXTextControl.dll from the setup.
Also in
TXTextControl.TextControl.ASP.SDK as TXTextControl.dll

Description

A SubTextPart object represents a user-defined part of a TX Text Control document. A TX Text Control document consists of the main text, and additionally other pieces of text such as text frames and headers or footers, called textparts. A programmer can define further parts called subtextparts to perform operations on smaller pieces of text. Each of the main textparts has a SubTextPartCollection which can be used to add and remove subtextparts or to save the subtextpart's text.

Syntax

public class 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);

Members

Constructors

ConstructorDescription
SubTextPartInitializes a new instance of the SubTextPart class.

Properties

PropertyDescription
DataGets or sets additional data of the subtextpart. An empty string indicates that the subtextpart has no data.
HighlightColorGets or sets the highlight color for the subtextpart. A subtextpart is highlighted, if it contains the current text input position. The color's alpha value must be less than 255 (opaque) so that the textpart's text remains visible. The default value is red with an alpha value of 60.
HighlightModeGets or sets a value indicating when the subtextpart is highlighted.
IDGets or sets the subtextpart's identifier. It must be a one-based value. A value of zero indicates that the subtextpart has no identifier.
LengthGets the number of characters which belong to the subtextpart.
NameGets or sets the name of the subtextpart. An empty string indicates that the subtextpart has no name.
NestedLevelGets the subtextpart's nested level. The top level is 1.
NumberGets the subtextpart's number. The first subtextpart has the number 1. The number is defined through the textflow. A textpart with a smaller start position has a smaller number. When an outer subtextpart has the same start position than one of its nested textparts the outer textpart has a smaller number.
OuterMostSubTextPartGets a subtextpart's outermost subtextpart. This is a top-level subtextpart with a nested level of 1. The property's value is an object of the type SubTextPart or null if this subtextpart is already a top-level subtextpart.
OuterSubTextPartGets a subtextpart's outer subtextpart. The property's value is an object of the type SubTextPart or null if this subtextpart is a top-level subtextpart.
StartGets the index (one-based) of the first character which belongs to the subtextpart.
TextGets the subtextpart's text.

Methods

MethodDescription
GetChildrenReturns an array of SubTextPart objects which are the children of this SubTextPart. The array contains all direct children and all further descendants in the order as they appear in the text.
GetTextFieldsReturns an array of TextField objects which are completely contained in this SubTextPart. The objects' type depend on the fieldType parameter.
SaveSaves the subtextpart's text with the specified format.
ScrollToSets the current input position to the beginning of a subtextpart and scrolls it into the visible part of the document.

Further Reading

  • The Power of SubTextParts: Typical Use Cases –
  • MailMerge: Rendering Conditional Table Rows –
  • X15 Sneak Peek: Upcoming JavaScript API Improvements in the HTML5-based Editor for ASP.NET MVC and Web Forms –
  • ASP.NET: Protected SubTextParts in TXTextControl.Web –