Set font at runtime
I've seen the tech-tip for looping through all report objects at runtime,
but where do I call the code from? I've tried it in the "BeforePrint"
event, but it doesn't work there. I've also tried it after generating the
report, then calling "refresh" with no luck.
I'm using a report hooked up to the TppViewer control, and generating the
report calling TppViewer.RegenerateReport.
but where do I call the code from? I've tried it in the "BeforePrint"
event, but it doesn't work there. I've also tried it after generating the
report, then calling "refresh" with no luck.
I'm using a report hooked up to the TppViewer control, and generating the
report calling TppViewer.RegenerateReport.
This discussion has been closed.
Comments
like?
--
Ed Dressel
Team DM
TppViewer.RegerateReport.
Actually, I figured out a way to get it to work. At form creation, I call
this:
procedure setupReportFont(aControl: TControl);
var
repeats: Integer;
begin
for repeats := 0 to aControl.ComponentCount - 1 do
begin
if aControl.Components[repeats] is TppComponent then
begin
if TppComponent(aControl.Components[repeats]).HasFont then
begin
TppComponent(aControl.Components[repeats]).Font.Name :=
'Default';
TppComponent(aControl.Components[repeats]).Font.Charset :=
DEFAULT_CHARSET;
end;
end;
end;
end;
So, in my "FormCreate" event, I just call setupReportFont(self), and it
changes any descendant of TppComponent. Then, when I print my report,
everything has the font I want.