TX Text Control .NET Server

Paragraph Class

Class|Introduced in 15.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

An instance of the Paragraph class represents a single paragraph in a Text Control document. Paragraphs are numbered from the beginning to the end of the document beginning with 1. A document has at least one paragraph. A Paragraph object can be obtained from the paragraphs collection available through the TextControl.Paragraphs property.

Syntax

public class Paragraph

Examples

The following example shows how to use the Paragraph class to add paragraph numbers and apply a format to each paragraph, that holds text, e.g. is longer than 3 characters.

TXTextControl.ParagraphFormat numberedParagraphFormat = new TXTextControl.ParagraphFormat();
numberedParagraphFormat.Alignment = TXTextControl.HorizontalAlignment.Left;
numberedParagraphFormat.LeftIndent = 200;
numberedParagraphFormat.RightIndent = 500;
numberedParagraphFormat.HangingIndent = 100;
foreach (TXTextControl.Paragraph p in textControl1.Paragraphs)
{
    textControl1.InputPosition = new TXTextControl.InputPosition(p.Start - 1);
        if (p.Length >= 3)
        {
            textControl1.Selection.Text = p.Number.ToString() + ". ";
            p.Format = numberedParagraphFormat;
        }
}

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

textControl.Text = "Quarterly results\nRevenue increased by 12%.";
Paragraph paragraph = textControl.Paragraphs[1];

Members

Properties

PropertyDescription
FormatGets or sets the paragraph's formatting attributes. The property's value is an object of the type ParagraphFormat.
FormattingStyleGets or sets the paragraph's formatting style. The specified style must be the name of a style contained in the ParagraphStyles collection of a Text Control document.
LengthGets the number of characters in the paragraph including the paragraph end character.
LinesGets the number of lines the paragraph consists of.
ListFormatGets or sets the paragraph's bulleted or numbered list and/or its formatting attributes. The property's value is an object of the type ListFormat.
ListNumberGets the paragraph's list number. It is zero, if the paragraph does not belong to a numbered list.
ListNumberTextGets the paragraph's list number text. The text consists of the text in front of the number, the number itself and the text behind the list number. It is an empty string, if the paragraph does not belong to a numbered list.
NumberGets the paragraph's number. The first paragraph has the number 1.
StartGets the number (one-based) of the paragraph's first character.
StartLineGets the number (one-based) of the paragraph's first line.
TextGets the paragraph's text.

Methods

MethodDescription
SaveSaves the paragraph's text with the specified format.
SelectSelects the paragraph. The paragraph break characters bounding the paragraph are not selected.

Further Reading