Make format changes at run time

I am in learning mode in Fast Reports and have not yet completed preschool??¦

I am using Delphi 7 (oops) and FR 4.0. I am stuck with both for this project.

I need to conditionally and dynamically make minor changes to formatting properties in Fast Reports. At this point in time, it looks like it will only involve changing font color in the header possibly background color of the header.

Like:
PageHeader1 - conditionally make all text blue or black
PageHeader1 - conditionally change background color

I have looked briefly at using FR style sheets and setting the path to the style sheet in an INI file. If prefer not to take the massive amount of time it would probably take me to weed through this endeavor, and from what I read ???The set of styles determines the design appearance of a whole report???.

I would like to do this through report variables if possible ??¦ likely so, but I am not well versed in using report variables either.

My extent of using report variables is creating them in the report editor via ???Menu Report- Variables??? .. and inserting the variable in the report.

I am conditionally setting the logo image path now, based on an ini file and a report variable created via the report menu and setting the variable in Delphi before the report is loaded. It took me hours of researching internet and the meager FR manuals to get to this and get it up and running:
procedure Picture1OnBeforePrint(Sender: TfrxComponent);
begin
if Get('LogoPath') <> '' then
picture1.loadfromfile(<LogoPath>);

This is the extent of my knowledge and use of variables in FR. ie, I am a little slow at FastReports, SO .. if there???s any interest in helping out here, please be gentle and specific regarding how to implement this using report variables, style sheets, or whatever.

Comments

  • edited 8:25AM
    Hi.

    I would do it like this:

    The PageHeader does not have a background-property, so you should add a shape (rectangle) to the band, behind the text (right-click -> send to back), to get background color.

    Then, add code to the PageHeader1.OnBeforePrint to alter format depending on variables:

    procedure PageHeader1OnBeforePrint(Sender: TfrxComponent);
    begin
    if Get('MyFontVariable') = 'Blue' then
    begin
    Memo1.Font.Color := clBlue;
    Memo2.Font.Color := clBlue;
    ...
    end;
    if Get('MyBackGrVariable') = 'Red' then
    Shape1.Color := clRed;
    end;

    If all your fonts in the band are the same, you can set the ParentFont-property for all of them, and just alter the PageHeader1.Font.Color in the event.
  • edited 8:25AM
    Petter S. wrote: »
    Hi.

    I would do it like this:

    The PageHeader does not have a background-property, so you should add a shape (rectangle) to the band, behind the text (right-click -> send to back), to get background color.

    Then, add code to the PageHeader1.OnBeforePrint to alter format depending on variables:

    procedure PageHeader1OnBeforePrint(Sender: TfrxComponent);
    begin
    if Get('MyFontVariable') = 'Blue' then
    begin
    Memo1.Font.Color := clBlue;
    Memo2.Font.Color := clBlue;
    ...
    end;
    if Get('MyBackGrVariable') = 'Red' then
    Shape1.Color := clRed;
    end;

    If all your fonts in the band are the same, you can set the ParentFont-property for all of them, and just alter the PageHeader1.Font.Color in the event.
  • edited 8:25AM
    Petter S: Works great. Thank you. [img]style_emoticons/<#EMO_DIR#>/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> firionicable: Good luck![/img]>

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.