Printing a table |
Top Previous Next |
A table can be printed in two modes:
In the first mode, the table is printed inside the band which it belongs to, and looks just the same as in the designer. In this mode, the table does not split across pages if its width is bigger than the width of the report page. This is the mode of printing by default.
The second mode is dynamic. In this mode, the table is built with the help of script. During this, the resulting table can be different from the initial table, just like the prepared report of FastReport differs from the report template. In dynamic mode, the table can split across pages if it does not fit on the report page.
In the dynamic mode, the table does not get printed on the band on which it was placed. Instead of this, the table itself generates a set of bands, which contain parts of the resulting table. This mode of work imposes the following limits:
Let us look at the dynamic mode in details.
This mode is connected with programming and needs higher qualifications from the report developer.
Formation of the table is done with the help of script. In order to create a script, select the "Table" object, in the "Properties" window click the "Events" button and double click on ManualBuild event:
When this is done, an empty event handler is added into the report code:
private void Table1_ManualBuild(object sender, EventArgs e) {
}
In this mode, the source table is used as a template. In the event code, you can print rows and columns from the source table as many times as it is needed. During this, the resulting table will be formed, which can contain an unlimited number of rows and columns. Such a table can split across pages if it does not fit on the report page.
For printing a table, the following methods of the "Table" object are used:
Printing a table can be done by using one of the following methods:
The first method - printing from top to bottom, then from left to right. This method fits better a table with a variable amount of rows. You must call the methods in the following order:
Every row of the table must contain the same number of columns. Keep it in mind, when using the PrintColumn(int index) and PrintColumns(int [] indices) methods.
The second method - printing from left to right, then from top to bottom. This method is better for printing a table with a variable number of columns. You must call the methods in the following sequence:
Every column of the table must contain the same number of rows. Keep it in mind, when using the PrintRow(int index) and PrintRows(int [] indices) methods.
Violation of the order of calling the printing methods leads to errors when executing the report. One of the errors - attempting to print the table with the help of the following code:
Table1.PrintRows(); Table1.PrintColumns();
This sequence of methods is not correct. You must start printing the table with either the PrintRow or PrintColumn method. |