How to manage the indentation on top of the second page of the report

2018-09-06

Often, when the report is displayed, you can observe how the data that does not fit on the first page is transferred to the second one. This is typical for the band "Data" and "Group header", and associated with them.

The Data band can contain data fields, or other objects, such as a table or matrix.

To make the first page completely filled with data, without spaces, you need to set the CanBreak property for the Data band. But what if you want the "rest" of the table on the second page to place below the top edge? For example at the level of the beginning of the table. At the same time, if you view two sheets of the report at the same time, it will look harmonious. There are no regular settings for this. However, we can always use the report script, and do everything.

Therefore, there are two ways to do this, and they are both very similar.

The first way:

  • Add the "Page title" band;
  • Add a BeforePrint event handler for this band;
  • In the event handler code, check the current page number, and if it's the second page, but change the height of the band to a suitable value.

Picking up the height of the "Page Title" band, we can achieve printing the table on the second page at the same level as on the first page.

The second method is almost identical to the first:

  • Add the "Page title" band;
  • Set the desired height in the properties;
  • Add a BeforePrint event handler to the "Page title" band;
  • In the event handler code, check the current page number, and if it's the second page, but display the band.

Just choose what you like, because both methods are equivalent,.

Now consider the code of the BeforePrint event handler for the "Page header" band.

The first way:

1
2
3
4
5
6
7
private void PageHeader1_BeforePrint(object sender, EventArgs e)
{
 if (Engine.CurPage > 0)
 PageHeader1.Height = 50; // Set top margin
 else
 PageHeader1.Height = 0;
}

 The second way:

1
2
3
4
5
6
7
private void PageHeader1_BeforePrint(object sender, EventArgs e) 
{ 
 if (Engine.CurPage > 0) 
 PageHeader1.Visible = true; 
 else 
 PageHeader1.Visible = false; 
} 

 As you can see, in the first case, we change the height of the band in the code, and in the second case, we display the band with a predetermined height.

As a result, we get an upper margin for the table on the second page of the report:

Thus you can adjust the margins for each subsequent page of the report.

November 26, 2024

Installing FastReport on .NET 8.0 and Creating a Simple Report

The purpose of this article is to explain step by step how to install FastReport on .NET 8.0 and how to create a simple report. Taking the reporting process from the beginning, it will show how to connect, design and view reports.
November 20, 2024

Localization and Language Switching in FastReport VCL

FastReport VCL supports 40 languages for interface localization and allows you to change the language on the fly through menus or code, without recompilation.
November 01, 2024

New Features of the FastReport VCL Editor

We are considering new features of the report editor: extension lines, highlighting of intersecting objects, updated report and data trees.
Fast Reports
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • info@fast-report.com
  • 66 Canal Center Plaza, Ste 505, Alexandria, VA 22314

© 1998-2025 Fast Reports Inc.