Dynamically adding pages to a single page template

edited June 2009 in FastReport 4.0
Hi,

Firstly the functionality I am trying to achieve is to dynamically add new report pages to a single page report template.

The template has 2 pictureviews and 2 memoviews inside a masterdata band.

When the user clicks the "Add New Page" button, I increment the row count of the masterdata band and call PrepareReport(false) which in result adds a new page to the preview.
However the the pictureview and memoview objects of the page which was just added has the same names as the first page, which is expected. So i give the new picviews and memoviews new names (i.e. picview2, memoview2)
There are now a total of 4 pictureviews and 4 memoviews in the report. I want to be able to access each pictureviews and memoviews which shall allow the user to add different content to each one.
However the problem is when PrepareReport() is called, I can no longer seem to access the previously added page with the following:
for(int i = 0; i < reportStandardReport->Engine->PreviewPages->Count; i++){
   TfrxReportPage* page = dynamic_cast<TfrxReportPage*>(reportStandardReport->Engine->PreviewPages->Page[i]);
}

The second page (when i = 1) is now NULL for some reason after PrepareReport() is called, even though the page count still remains at 2. Where did that page go?

I have tried many ways to achieve my desired functionality including the following:
* Storing pointers to the pictureviews and memoviews in array, however the contents to where the pointers are pointing seem to change when PrepareReport() is called...

Please, can someone please guide me to the best way to dynamically add a new page to a single page report where each pictureview and memoview can be accessed individually? One way I can think of is to create a multipage report template and name each picview and memoview individuallym but this is not efficient and I am then limited to the amount of pages I have in the template. Thanks.

Comments

  • Anu de DeusAnu de Deus Hampshire, UK
    edited June 2009
    I don't really know the answer to your problem, but I can give you an idea for you to expand and see if it works.
    What few people know is that you can add multiple MasterData bands to your page, one after the other.
    I have a program that automatically adds contents to the reports by adding data bands to it. So, to add a new picture, I add a databand, then put the picture on it. If I want another one, with a richview object, it's another data band I create with the richview on it. In the end I have reports with more than 20 masterdata bands in one page. In these cases, I don't need a dataset assigned to them, but I set the rowcount to 1.
    So, if you know you are going to have just one extra page (and not a dynamic number), then add just a second MasterData band with your 2 extra components in it. Dont forget to set the rowcount to 1.
    You can also do that at design time: create both bands, but make the 2nd invisible, and under certain user action only then you make the 2nd visible.
    Let me know if it helped.
    Cheers

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.