Paper Size change (letter to A4) and centered titles
What's the best way to recenter a title upon a paper size change? I've had
to deal with A4 for some time now, but this is the first report I've had in
landscape where the titles will look screwy (well...so will the rest of the
report for that matter). We need some sort of 'auto center' for paper
size changes. heh..we also need some sort of 'best fit columns' based upon
percentage off columns. That would be neat.
Thanks!
Nick H
to deal with A4 for some time now, but this is the first report I've had in
landscape where the titles will look screwy (well...so will the rest of the
report for that matter). We need some sort of 'auto center' for paper
size changes. heh..we also need some sort of 'best fit columns' based upon
percentage off columns. That would be neat.
Thanks!
Nick H
This discussion has been closed.
Comments
If you are loading templates, you could use the template events to
re-position each report component using an object loop. I would suggest
using the OnLoadEnd event as your starting point. Check out the articles
below on how to use the template events and create a report object loop.
----------------------------------------------
Tech Tip: Using Template Events
----------------------------------------------
The Report.Template object has several events that can be used for
customizing what happens when a report is loaded or saved:
- OnLoadStart
- OnLoadEnd
- OnNew
- OnSaveStart
- OnSaveEnd
The OnLoadEnd and OnNew events are often used to perform actions related
to report and data initialization.
The OnSaveEnd event is often used to save additional descriptive
("meta") data to the database each time the report is saved.
Example:
The Report.Template events are public and therefore must be assigned at
run-time.
1. In the private section of your form declaration you can declare an
event-handler method:
TForm = class(TForm)
private
procedure myTemplateOnLoadEndEvent(Sender: TObject);
public
end;
2. In the Form.OnCreate event, you can assign the event-handler to the
event:
procedure TForm1.FormCreate(Sender: TObject);
begin
ppReport1.Template.OnLoadEnd := myTemplateOnLoadEndEvent;
end;
3. Implement the event-handler method:
procedure TForm1.myTemplateOnLoadEndEvent(Sender: TObject);
begin
{add code here to initial the report or data, etc. }
ppReport1.PrinterSetup.MarginTop := 0.5;
end;
----------------------------------------------
Tech Tip: Loop Thru All Objects in a Report
---------------------------------------------
A ReportBuilder report is composed of a set
of components. The basic structure is
Reports.Bands[].Objects[]
The bands and objects within the report can
be accessed directly by object name or
via the Bands and Objects array properties.
Below is an example of using the Bands and
Objects array properties to change the font for
all objects on a report.
uses
ppClass;
procedure AssignFontToReport(aFont: TFont; aReport: TppCustomReport);
var
liBand: Integer;
liObject: Integer;
lObject: TppComponent;
begin
for liBand := 0 to aReport.BandCount-1 do
for liObject := 0 to aReport.Bands[liBand].ObjectCount-1 do
begin
lObject := aReport.Bands[liBand].Objects[liObject];
if lObject.HasFont then
lObject.Font := aFont;
end;
end;
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com