KeepLinesTogether Property
- Namespace
TXTextControl
- Package
TXTextControl.asTextControl. WPF. SDK TXTextControl.from the private NuGet feed or Text Control Offline Packagesdll
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; }Public Property KeepLinesTogether As BooleanExamples
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;textControl.Text = "First item" & vbCrLf & "Second item" & vbCrLf & "Third item"
textControl.Select(0, textControl.Text.Length)
Dim paragraphFormat As ParagraphFormat = textControl.Selection.ParagraphFormat
paragraphFormat.KeepLinesTogether = True
If paragraphFormat.KeepLinesTogether Then
Console.WriteLine("Paragraph Format: Keep Lines Together is enabled.")
End If
textControl.Selection.ParagraphFormat = paragraphFormatRemarks
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.