| Home->
Tutorial->Sections with report design
In this step, You will learn the mechanism and procedure of report
rendering and printing. Also you can learn about Canvas, sections(Report
Header/Footer band, Page Header/Footer band, Group Header/Footer band
and Detail band) and ActiveScripting technology.
Format
A report section contains a group of controls that are processed and
printed at the same time as a single unit. Designer Studio defines the
following section types:

Report Header
A report can have one report header section that prints at the beginning
of the report. It is generally used to print a report title, a summary
table, a chart or any information that needs to appear only at the report's
start
Report Footer
A report can have one report footer section that prints at the end of the report.
It is used to print a summary of the report, grand totals or any information that
needs to print once at the report's end.
Page Header
A report can have one page header section that prints at the top of each page.
It is the first section that prints on the page except when the page contains
a report header section. The page header section is used to print column headers,
page numbers, a page title or any information that needs to appear at the top of each page.
Page Footer
A report can have one page footer section that prints at the bottom
of each page. It is used to print page totals, page numbers or any other
information that needs to appear at the bottom of each page.
Group Header, Group Footer
A report can consist of single or multiple (nested) groups, with each
group having its own header and footer sections. The header section(s)
are inserted and printed immediately before the detail section. The
footer section(s) are inserted and printed immediately after the detail
section.
The number of times each group section prints depends on how the data
is grouped. ActiveReports starts a new group (Header, Detail, and Footer)
when the data to which the group is bound changes.
Detail
A report has one detail section. The detail section is the body of the report
and one instance is created for each record in the report.
Report Processing
The speed in processing and output generation of ActiveReports is attributed
to its intelligent, multi-threaded, single-pass processing. ActiveReports
will process and render each page as soon as the page is ready. If ActiveReports
is not able to fully render a page because some of its data elements
are not known, or its layout is not final, it places the page in cache
until that data is available.
Summary fields and KeepTogether constraints are the two reasons that
a page would not be displayed immediately. The summary field is not
complete until all the data needed for calculation is read from the
data source. When a summary field such as a grand-total is placed ahead
of its completion level such as placing it in the report header, the
report header section and all following sections will be delayed until
all the data is read.
Printing Process
ActiveReports' output can be printed using different methods. The simplest
is to call the PrintReport method. When the PrintReport method is called,
ActiveReports checks to determine if the report has been processed earlier.
If not, it starts the report processing to create the Pages collection.
Then it starts a new print job and prints each page in the collection
then ends the print job.
You can call the Stop or Cancel methods while the report is processing
or printing. Both methods will cause the print job to end. The Stop
method will continue to print processed pages before closing the print
job. The Cancel will immediately close the print job and clear the pages
collection.
In addition, you can call the Run method to process the report and create
the pages collection. Next, start a print job using the Printer.StartJob
method. Then, selectively print pages from the collection using the
Printer.PrintPage method. Finally, close the print job using the Printer.EndJob
method.
If you use background printing using Run(True) you will receive PrintProgress
events. The Status property is updated while the report is printing
in the background.
Section Events
Regardless of the sections type or content, there are three events for
each section: Format, BeforePrint, and AfterPrint.
Because there are so many possible report designs, the event firing
sequence must be dynamic in order to accommodate individual report demands.
Out of these three events, the Format event is generally used the most,
followed by the BeforePrint event, and in rare circumstances, the AfterPrint
event.
| Note
: The only guaranteed sequence of events is for each section
to fire the Format event before firing the BeforePrint event, which
in turn, occurs before the AfterPrint event. However, several Format
events may fire for multiple detail records before their BeforePrint
and AfterPrint events fire. |
Format
This event fires after the data is loaded and bound to the controls contained in a section,
but before the section is rendered to the canvas.
The format event is the only event where the section's height may be changed. This section
may be used to set or change the properties of any controls, or load subreport controls with
subreports.
If the CanGrow or CanShrink property of any control contained within a section, or
the section itself, is set to true, all of the growing and shrinking of controls contained
in this section, and the section itself, takes place in this event. Because of this,
information about a control or section's height cannot be obtained in this event.
BeforePrint
This event fires before the section is rendered to the canvas.
The growing and shrinking of the section and all controls contained in a section have already
taken place by the time this event fires. Use this section to resize any controls if needed.
Since all controls and section growth have already taken place by the time this event fires,
this event may be used to get an accurate height of the section or, if needed, any controls
contained in it. You may resize any controls in this event but you cannot resize the section
itself.
AfterPrint
This event fires after the section is rendered to the canvas.
Although Detail AfterPrint originally started off as a very important event prior to Version 1
Service Pack 3, it is rarely used in any of the newer builds of ActiveReports. When you are
placing code in the section events, chances are you are going to be placing your code in the
Format or BeforePrint events. This event is still useful for drawing on the canvas after text
has already been rendered to the canvas.
|