TX Text Control .NET for Windows Forms Documentation

Paragraph Class

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.

Introduced: 15.0.

Syntax

[C#] public class Paragraph
[Visual Basic] Public Class Paragraph

Properties

PropertyDescription
FormatGets or sets the paragraph's formatting attributes.
FormattingStyleGets or sets the paragraph's formatting style.
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.
ListNumberGets the paragraph's list number.
ListNumberTextGets the paragraph's list number text.
NumberGets the paragraph's number.
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
SaveOverloaded. Saves the paragraph's text in a byte array or as a string with a specified format.
SelectSelects the paragraph.

Example

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.

[C#] 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; } }
[Visual Basic] Dim numberedParagraphFormat As New TXTextControl.ParagraphFormat(TXTextControl.HorizontalAlignment.Left) numberedParagraphFormat.Alignment = TXTextControl.HorizontalAlignment.Left numberedParagraphFormat.KeepLinesTogether = True numberedParagraphFormat.LeftIndent = 200 numberedParagraphFormat.RightIndent = 500 numberedParagraphFormat.HangingIndent = 100 For Each p As TXTextControl.Paragraph In TextControl1.Paragraphs TextControl1.InputPosition = New TXTextControl.InputPosition(p.Start - 1) If p.Length >= 3 Then TextControl1.Selection.Text = p.Number.ToString() + ". " p.Format = numberedParagraphFormat End If Next

See Also

 
 
 

Products

Support

Downloads

Corporate

Buy Now