TX Text Control .NET for Windows Forms

KeepWithNext 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

If this property is set to true, the paragraph is displayed on the same page as its following paragraph.

Syntax

public bool KeepWithNext { get; set; }

Examples

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

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

paragraphFormat.KeepWithNext = true;
if (paragraphFormat.KeepWithNext)
{
    Console.WriteLine("Paragraph Format: Keep With Next 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.

Further Reading