New to Telerik UI for WPF? Download free 30-day trial

Repeat Table Header Row

When working with large tables, they are visualized in more than one page. Header row repetition means that the header row(s) of a table will repeat at the top of each page on which the table spans. This article will show you how to work with this feature.

Overview

RadRichTextBox allows you to set a repeating header row for a table. You are free to choose whether there will be a single repeating row or multiple consecutive ones. The requirement for this feature to be visible is the table will span on two or more pages.

When the table header row is visible, a new (the same as the header row) row is visualized on the top of every slice of the table. This is only a visual change of the table representation – actually, a new row hasn’t been added to the table. Figure 1 shows what a table divided that spans over two pages looks like when its first row is configured to repeat on each page.

Figure 1: Table with repeat header row applied

RadRichTextBox Features Repeat Table Header Row 02

The feature is visible only in Paged layout mode and when printing (Print Preview). Repeating table rows was introduced in Q1 2016.

How to Use a Repeat Table Header Row

You can set one or more rows as a repeat table header row(s) consecutively. In other words, if row N is added as a repeated header row, row N+1 can be added as well. However, if row N is not added to repeat on each page, row N+1 cannot be added. A gap of non-repeated header rows cannot exist between two rows that you want to mark as repeated header rows. Note that you must always include the first row of the table.

When there isn’t enough space for the next non-repeating header row to be drawn on the page, the header row is not repeated – the row is drawn only on the first page (the page where the table begins).

Programmatically via the RadRichTextBox API

The TableRow class exposes a property called RepeatOnEveryPage of type bool. Example 1 shows how to set a row to repeat on each page the table appears on.

Example 1: Set a Repeat Table Header Row using the RepeatOnEveryPage property

TableRow row = new TableRow(); 
row.RepeatOnEveryPage = true; 
Dim row As New TableRow() 
row.RepeatOnEveryPage = True 

Another option is to use the ChangeTableRowRepeatOnEveryPage() method of RadRichTextBox, which allows you to change whether a row will be repeated or not. Example 2 demonstrates how to get the first TableRow in a RadDocument and set it as a repeated header row.

Example 2: Set a Repeat Table Header Row using the ChangeTableRowRepeatOnEveryPage() method

TableRow firstRow = this.radRichTextBox.Document.EnumerateChildrenOfType<TableRow>().First(); 
this.radRichTextBox.ChangeTableRowRepeatOnEveryPage(firstRow); 
Dim firstRow As TableRow = Me.radRichTextBox.Document.EnumerateChildrenOfType(Of TableRow)().First() 
Me.radRichTextBox.ChangeTableRowRepeatOnEveryPage(firstRow) 

Via the Built-in UI

Using the UI of RadRichTextBox, you have the ability to add or remove header rows.

The TableProperties dialog gives you a simple UI to add or remove a repeating header row.

Figure 2: The RadRichTextBox Table Properties dialog

RadRichTextBox Features Repeat Table Header Row 0

Through the dialog you can set only the first row from the table as a repeated header row. If another row is chosen (click on the next, previous row buttons), the checkbox is disabled.

Repeating table header row(s) could be added or removed via the Table Tools’ contextual tab Layout, which contains a toggle button that sets the row as a repeating header row or not. To learn more about how to use the RadRichTextBoxRibbonUI, you could read this topic.

Using this approach, header rows can be added consecutively. In other words, if row N is added as repeated header row, row N+1 can be added as well. However, if the row N is not added to repeat on each page, row N+1 cannot be added. A gap of non-repeated header rows cannot exist between two rows that you want to mark as repeated header rows.

Figure 3: Repeat Table Header Rows button in the Table Tools contextual menu

RadRichTextBox Features Repeat Table Header Row 1

See Also

In this article