TX Text Control .NET for Windows Forms

KeepLinesTogether Property

Property|Introduced in 13.0
Namespace
TXTextControl
Package
TXTextControl.TextControl.WinForms.SDK as TXTextControl.dll from the private NuGet feed or Text Control Offline Packages

Description

Gets or sets a value indicating whether a page break is allowed within the paragraph. If the property's value is true, a page break is not allowed. Otherwise, it is allowed.

Syntax

public bool KeepLinesTogether { get; set; }

Examples

The following example applies paragraph layout to selected report text by using ParagraphFormat.KeepLinesTogether.

textControl.Text = "First item\nSecond item\nThird item";
textControl.Select(0, textControl.Text.Length);
ParagraphFormat paragraphFormat = textControl.Selection.ParagraphFormat;

paragraphFormat.KeepLinesTogether = true;
if (paragraphFormat.KeepLinesTogether)
{
    Console.WriteLine("Paragraph Format: Keep Lines Together is enabled.");
}

textControl.Selection.ParagraphFormat = paragraphFormat;

Remarks

The property's default value is false.

The property returns its default value when the text selection contains multiple paragraphs with mixed setting. The Selection.IsCommonValueSelected method can be used to check for mixed attributes.