TX Text Control .NET for WPF

Line Class

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

Description

An instance of the Line class represents a single line in a Text Control document.

Syntax

public class Line

Examples

The following example shows how to read the document line by line.

textControl1.Text = "Line 1\nLine 2\nLine 3";

foreach (TXTextControl.Line line in textControl1.Lines)
{
    Console.WriteLine("Line #" + line.Number.ToString() + " starts at: " +
        line.Start.ToString() + ". Text: " + line.Text);
}

The following example examines the first line in a short document.

textControl.Text = "Quarterly results\nRevenue increased by 12%.";
Line line = textControl.Lines[1];

Members

Properties

PropertyDescription
BaselineGets the line's baseline position. The value is given in twips with an origin at the upper left corner of the document. The relationship between the upper left corner of the document and the upper left corner of the visible portion of the document can be obtained with the TextControl.ScrollLocation property.
LengthGets the number of characters in the line including the break character.
NumberGets the line's number. The first line has the number 1.
PageGets the number of the page to which the line belongs. The first page has the number 1.
StartGets the number (one-based) of the first character in the line.
TextGets the line's text.
TextBoundsGets the bounding rectangle of the text belonging to the line. The values are given in twips with an origin at the upper left corner of the document. The relationship between the upper left corner of the document and the upper left corner of the visible portion of the document can be obtained with the TextControl.ScrollLocation property.

Methods

MethodDescription
SaveSaves the line's text with the specified format.