Text can be manipulated in many ways using the TX Text Control API. Depending on the current task, various classes can be used to set the input position, to retrieve the text or to set the text at the current input position.

The Basics: The Input Position

The following two properties can be used to manipulate the input position:

Both classes can be use to set the input position to a specific character index which is 0-based.

TX Text Control Input Position

Selection Class

The following code uses the Selection TX Text Control .NET Server for ASP.NET
TXTextControl Namespace
Selection Class
The Selection class describes and handles the attributes of a text selection.
class to set the input position to the index location 3 which is the beginning of character location 4.

Loading...

The Selection class can be now used to select a range of text in order to replace it with new text.

Loading...

Selecting Text

Although the above code works, the Selection class should be used in a different way. The Selection TX Text Control .NET Server for ASP.NET
TXTextControl Namespace
ServerTextControl Class
Selection Property
Gets or sets the current selection in the main text of the document.
property accepts a complete Selection object. The object can be prepared and then applied to the text as shown in the code snippet below.

Loading...

InputPosition Class

The InputPosition TX Text Control .NET Server for ASP.NET
TXTextControl Namespace
InputPosition Class
An instance of the InputPosition class represents the current text input position of a TXTextControl document.
constructor offers other possibilities to set the input position. This class can be used to set the input position in case the X and Y coordinates are known or a specific page, column and row number is used. The following implementations of the constructor are available:

Loading...

To set the input position to index 3 similar to the above sample using the Selection property, the following code is required.

Loading...

Retrieving Text

In order to retrieve text from a specific range of text, the Selection class must be used. The following code shows how to retrieve the string "Text" from the above sample.

Loading...

To get the formatted text in any supported format, the Selection.Save TX Text Control .NET Server for ASP.NET
TXTextControl Namespace
Selection Class
Save Method
Saves the selected text of a document with the specified format.
method can be utilized. The following code shows how retrieve the word "Text" in HTML format.

Loading...

The variable htmlString contains the word "Text" in HTML format.

Loading...

Retrieving Text without Selecting Text

Using the above methods the text must be selected to retrieve the text. The TextChar TX Text Control .NET Server for ASP.NET
TXTextControl Namespace
TextChar Class
An instance of the TextChar class represents a single character in a Text Control document.
class can be used to retrieve a character at a specific location without setting the input position to that location. The following code returns the character "T" at index 4.

Loading...

The Line TX Text Control .NET Server for ASP.NET
TXTextControl Namespace
Line Class
An instance of the Line class represents a single line in a Text Control document.
class can be used to retrieve text from a specific line. The following code returns the complete text of the first line.

Loading...

The third option to retrieve text without selecting text is the usage of the Paragraph TX Text Control .NET Server for ASP.NET
TXTextControl Namespace
Paragraph Class
An instance of the Paragraph class represents a single paragraph in a Text Control document.
class that represents a complete paragraph including text and formatting. The following code returns the plain text of the complete paragraph based on input position 3.

Loading...