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

Copy Components in Report?

edited August 2002 in General
I am trying to make a copy of a region in a report at run time. Ofcourse,
all the components on the region must also be copied to the new region as
well. I tried using "Assign" method of the TppRegion. But it gave me "Cannot
assign TppRegion to a TppRegion" error .Seems like the "Assign" method of
the TppRegion is not implemented. Can anybody suggest a good method of
making a copy of a Region at run time?

Thanks,
Vikram

Comments

  • edited August 2002
    You've created a new region object at runtime. You can loop through the
    objects in the original region using the region's Objects[] array property.
    So you can loop through the objects, that is fine, but you need to clone
    them, so you have to pull the class out from each object, instantiate one,
    and then assign the properties of the object. This is a lot of work. What
    you can do is do what the designer does, and stream a copy of the region
    down, and them stream it back up into an object. Take a look is
    ppDsgner.pas at the TppDesignerWindow's SelectionToClipboard and
    ClipboardToSelection methods.


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited August 2002
    Turns out that it is not all that hard work to loop thru the source region's
    objects and create similar components in the destination region.
    Since I need to change the properties of the objects after copying its
    probably easier for me to create them one-by-one and set the props.

    Thanks for the tip.

    Vikram

This discussion has been closed.