Search code examples
vb.netdelphifastreport

FastReports: Adding Objects to other than OverlayBand


I am writing a FastReport from code (not using the designer), the report eventually to be exported to a file.

If I export the report created from code to a .fpx - a report preview file, the file's bands do not appear when opened in "Edit Page" mode via the designer (though the bands' contents - e.g. data - does). The report is rendered, correctly - the content is where it needs to be. The only band that is present is the OverlayBand - not explicitly created by me in the code.

If I add band objects through code - for instance, a DataBand object - how do I ensure the added objects are: [1] added to the report, itself; and [2] not absorbed (?) by - or, added to - the OverlayBand object.

I consulted the scant documentation and have not found an answer. I am not looking for you to code the report for me. My thought is that I am missing a critical piece of the creation-from-code puzzle, e.g. the addition of further layers (not bands) to the report page.

Currently, I am instantiating a report:

Dim rptReport As New Report
Dim rptPage As New ReportPage
rptReport.Pages.Add(prtPage)

Further objects are then added to the the rptPage.Bands using:

' Pseudo-code:
rptPage.Bands.Add(aBandObject)

Must I explicitly add layers to the page before I can begin adding bands to it? My thought is that there is code that must enable the addition of bands to layers other than the overlay band, i.e.:

Dim rptReport As New Report
Dim rptPage As New ReportPage
rptReport.Pages.Add(prtPage)

' CODE INSERTED HERE: rptPage.Objects.Add(Bands) (Pseudo-code)

Again, if you are able to point in the right direction, I am okay with that; however, I have consulted the forums and documentation and am unable to find an answer - hence my asking, here.


Solution

  • From what I can see, the issue does not appear to arise from the code.

    When saved as a .fpx file and then opened in "Edit Mode", it remains true that the bands disappear; however, if I run rptObject.Design() and open the report that way, the bands appear as they should.

    The problem appears to arise from saving the file as a .fpx, the "preview" file (as opposed to .frx)