The following article does this in code. You could create a little utility function in your app that the end user could run to select a report from a list, and change all of the fonts in that report:
---------------------------------------------- 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.
Hi, This solution is working fine. but I am facing one problem while implementing this. This mechanism doesn't refresh the current page showing in the report.when you either move to next or previous page it changes the font. For refreshing the cureent page I have tried all the options like report.reset viewer.refresh viewer.refreshpage etc etc
none of the options is working except viewer.regeneratereport or report.printtodevices I can't refresh the page by generating the whole report again.because I am setting master detail relationship manually and for this I am quering database on DetailBandBeforePrint method for details records. I don't want to query database only for changing the font because it affects the performance a lot. can anybody suggest any other solution for my problem.
If you want to refesh the page, the report will have to be regenerated, since the font may affect how much space the controls use on the page, and this would affect the positions of other objects on each page.
If you are going to take this approach to send the detail queries, then you are not going to want to use the DetailBand.BeforePrint event to send the query. Use the BeforeGenerate event, as it fires a little less often than BeforePrint. This happens because groups and KeepTogether action will cause the detail band to attempt printing, until it runs out of space. It wil then try to fit on the next page. It will refire its events and regenerate for the second page.
Comments
function in your app that the end user could run to select a report from a
list, and change all of the fonts in that report:
----------------------------------------------
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
else if (lObject is TppSubreport) then
AssignFontToReport(aFont, TppSubreport(lObject).Report);
end;
end;
Tech Support mailto:support@digital-metaphors.com
Digital Metaphors http://www.digital-metaphors.com
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
This solution is working fine. but I am facing one problem while
implementing this. This mechanism doesn't refresh the current page showing
in the report.when you either move to next or previous page it changes the
font.
For refreshing the cureent page I have tried all the options like
report.reset
viewer.refresh
viewer.refreshpage etc etc
none of the options is working except
viewer.regeneratereport or
report.printtodevices
I can't refresh the page by generating the whole report again.because I am
setting master detail relationship manually and for this I am quering
database on DetailBandBeforePrint method for details records.
I don't want to query database only for changing the font because it affects
the performance a lot.
can anybody suggest any other solution for my problem.
Thanx in advance
Uma Tripathi
since the font may affect how much space the controls use on the page, and
this would affect the positions of other objects on each page.
If you are going to take this approach to send the detail queries, then you
are not going to want to use the DetailBand.BeforePrint event to send the
query. Use the BeforeGenerate event, as it fires a little less often than
BeforePrint. This happens because groups and KeepTogether action will cause
the detail band to attempt printing, until it runs out of space. It wil then
try to fit on the next page. It will refire its events and regenerate for
the second page.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com