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

Create components in BeforeDetailBandGenerate

edited July 2014 in General
Hi,

I'm using Delphi 2009 and RB 14 Professional.

I'm trying to create some labels during the detail band's before
generate event, but although they are created without error, they don't
appear on the report the first time I run it. If I run it a second time
they appear fine (the components are not destroyed in between, so they
already exist by the time the report is run a second time).

Is there anything I can do to get the components to show the first time
the report is run?

Thanks,

Steve Branley

Comments

  • edited July 2014
    Hi Steve,

    The BeforeGenerate is likely too late to add components to a band. Try
    using an earlier event such as the BeforePrint or StartPage of the report.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2014
    Hi Nico,

    Thanks for that. I had a feeling you were going to say it was too late.
    Trouble is, I can't do what I need to do any earlier.
    Might have to have a rethink.

    Thanks,

    Steve

  • edited July 2014
    Hi Steve,

    One option would be to manually add lower level drawcommands to the page
    rather than components. Drawcommands are positioned in page coordinates
    in microns so some conversion will need to be done to position them
    correctly. You should be able to use the Band.PrintPosRect as a
    starting point.

    Take a look at the following article on manually adding a watermark to a
    page. You could do something similar in the BeforeGenerate event of the
    band.

    http://www.digital-metaphors.com/rbWiki/Delphi_Code/Formatting/How_To...Manually_Add_a_Watermark_to_a_Page


    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2014
    Thanks Nico, that gives me something to explore at least!

  • edited July 2014
    Nico,

    This looks to be just what I need with just one problem: PrintPosRect is
    (0,0,0,0) every single time for the detail band, yet there are several
    detail records on the page. Is there any other way of working out the
    page position?

    Thanks,

    Steve


  • edited July 2014
    Hi Steve,

    I apologize, try using the PrintPosRect property of the report engine
    rather than the band.

    Report.Engine.PrintPosRect

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2014
    Perfect, Nico. Works like a charm. Thanks very much.

    Steve


This discussion has been closed.