
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.
[C#]
public class Paragraph
[Visual Basic]
Public Class Paragraph
| Property | Description | |
| Format | Gets or sets the paragraph's formatting attributes. | |
| FormattingStyle | Gets or sets the paragraph's formatting style. | |
| Length | Gets the number of characters in the paragraph including the paragraph end character. | |
| Lines | Gets the number of lines the paragraph consists of. | |
| ListFormat | Gets or sets the paragraph's bulleted or numbered list and/or its formatting attributes. | |
| ListNumber | Gets the paragraph's list number. | |
| ListNumberText | Gets the paragraph's list number text. | |
| Number | Gets the paragraph's number. | |
| Start | Gets the number (one-based) of the paragraph's first character. | |
| StartLine | Gets the number (one-based) of the paragraph's first line. | |
| Text | Gets the paragraph's text. |
| Method | Description | |
| Save | Overloaded. Saves the paragraph's text in a byte array or as a string with a specified format. | |
| Select | Selects the paragraph. |
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