Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Reload report from dfm

edited May 2009 in General
Hi,

in my application every form owns a report instance. The report is stored
inside the dfm as usual.
To allow end user customizations we added support for load/save reports
from/to database (Report.Template.LoadFromDatabase / SaveToDatabase).

Of course loading a report from database delete the "original" one loaded
from dfm.

Is there a way to reload the orginal report from the dfm ?

(Delphi 2006 + Report Builder 11)

Kind regards,
Corrado

Comments

  • edited May 2009


    You cannot reload from the .dfm, but you can easily save/reload the original
    report. Add some code, to the Form.OnCreate event or prior to calling
    Designer.ShowModal, to save the report definition to a memory stream.

    FOriginalReportStream: TMemoryStream;

    FOriginalReportStream:= TMemoryStream.Create;

    // save origin report definition
    myReport.Template.SaveToStream(FOriginalReportStream);


    // load original report definition
    FOriginalReportStream.Stream.Position := 0;

    myReport.Template.LoadFromStream(FOriginalReportStream);




    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited May 2009
    A few other ideas besides Nard:

    1) Create a new instance of the form.
    2) There are some VCL reset functions avaiable for restoring the original
    state of a componnet (form) I've seen. I have not seen them for a few years
    now, but I know they were around--maybe google or ask in the Delhpi
    newsgroups.

    Ed Dressel
    Team DM
This discussion has been closed.