# ParagraphFormat.KeepLinesTogether Property

> 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.

- **Product:** TX Text Control .NET Server
- **Section:** Reference
- **Kind:** Property
- **Introduced:** 13.0
- **Namespace:** `TXTextControl`
- **Package:** `TXTextControl.TextControl.Core.SDK` (assembly `TXTextControl.Core.dll`, from the private NuGet feed or Text Control Offline Packages)
- **Package:** `TXTextControl.TextControl.ASP.SDK` (assembly `TXTextControl.dll`, from the private NuGet feed or Text Control Offline Packages)
- **.NET Framework:** reference `TXTextControl.dll` from the setup
- **Path:** TX Text Control .NET Server > Reference > TXTextControl > ParagraphFormat.KeepLinesTogether Property
- **709 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/paragraphformat/keeplinestogether-property/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/paragraphformat/keeplinestogether-property/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/paragraphformat/keeplinestogether-property/llms-full.txt

---

### 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

```csharp
public bool KeepLinesTogether { get; set; }
```

```vbnet
Public Property KeepLinesTogether As Boolean
```

### Examples

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

```csharp
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;
```

```vbnet
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 = 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](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/selection/iscommonvalueselected-method/llms-full.txt) method can be used to check for mixed attributes.

---

## Nearby

- **Previous:** [ParagraphFormat.Justification Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/paragraphformat/justification-property/llms-full.txt)
- **Next:** [ParagraphFormat.KeepWithNext Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/paragraphformat/keepwithnext-property/llms-full.txt)
