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.
RadRichTextEditor 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 a table which spans 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 that spans over two pages looks like when its first row is repeated on each page.
The feature is visible only in Paged layout mode and when printing (Print Preview). Repeating table rows was introduced in Q1 2016.
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).
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.
Set a Repeat Table Header Row using the RepeatOnEveryPage property.
var row = new Telerik.WinForms.Documents.Model.TableRow();
row.RepeatOnEveryPage = true;
Dim row = New Telerik.WinForms.Documents.Model.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. The below code snippet demonstrates how to get the first TableRow in a RadDocument and set it as a repeated header row.
Set a Repeat Table Header Row using the ChangeTableRowRepeatOnEveryPage method.
var firstRow = this.radRichTextEditor1.Document.EnumerateChildrenOfType<Telerik.WinForms.Documents.Model.TableRow>().First();
Dim firstRow = Me.radRichTextEditor1.Document.EnumerateChildrenOfType(Of Telerik.WinForms.Documents.Model.TableRow)().First()
Using the UI of RadRichTextEditor, 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.
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 check box 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.