Paragraph Class
- Namespace
TXTextControl
- Package
TXTextControl.from the private NuGet feed or Text Control Offline PackagesTextControl. WPF. SDK
- Assembly
TXTextControl.dll
- Install
dotnet add package TXTextControl..NET 8 and later. For .NET Framework, referenceTextControl. WPF. SDK TXTextControl.from the setup.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 ParagraphPublic Class ParagraphExamples
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;
}
}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
NextThe following example examines the first paragraph in a short document.
textControl.Text = "Quarterly results\nRevenue increased by 12%.";
Paragraph paragraph = textControl.Paragraphs[1];textControl.Text = "Quarterly results" & vbCrLf & "Revenue increased by 12%."
Dim paragraph As Paragraph = textControl.Paragraphs(1)Members
Properties
| Property | Description |
|---|---|
| Format | Gets or sets the paragraph's formatting attributes. The property's value is an object of the type ParagraphFormat. |
| FormattingStyle | Gets 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. |
| 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. The property's value is an object of the type ListFormat. |
| ListNumber | Gets the paragraph's list number. It is zero, if the paragraph does not belong to a numbered list. |
| ListNumberText | Gets 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. |
| Number | Gets the paragraph's number. The first paragraph has the number 1. |
| 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. |