Class
RBReportDocument
Description
Used to store the report pages after a report has been run. It is part of the Reports Module module.
Property descriptions
RBReportDocument.PageCount
PageCount As Integer
Returns the number of pages rendered.
This property is read-only.
Method descriptions
RBReportDocument.Page
Page(Index As Integer) As Picture
Returns the passed page as a Picture. Page is 1-based.
RBReportDocument.Print
Print(g As Graphics)
Prints the pages to the specified graphics output device.
Notes
The RBReportDocument class is part of the Reports Module module. It returns the document after a report has been run. A report consists of one or more pages as Picture objects. You can refer to a page using its index. You can display the pages to the user in a Canvas control or print the pages.
Sample code
See the modified Example Database project that returns both a simple report and report with a break level. See also the Gas Report project that prints a simple listing without a break levels.
In the Gas Report example project, the RBReportDocument returned by the reporting engine is passed to the instance of the Report class:
Var ds As New GasDataSet // Reports.DataSet object
Var ps As New PrinterSetup
Var rpt As New GasPricesReport
If rpt.Run(ds, ps) Then
If rpt.Document <> Nil Then ReportViewer1.SetDocument(rpt.Document)
End If
The SetDocument method gets the current page of the report so that it can be imaged.
Sub SetDocument(doc As Reports.RBReportDocument)
mDocument = doc
mCurrentPage = 1
If doc.PageCount > 0 Then SetCurrentPage(mCurrentPage)
End Sub
SetCurrentPage gets the picture of the current page.
Sub SetCurrentPage(pageNum As Integer)
mCurrentPage = pageNum
mCurrentPicture = mDocument.Page(mCurrentPage)
ScrollBar1.Maximum = mCurrentPicture.Height - Canvas1.Height
ScrollBar1.Value = 0
Canvas1.Refresh(False)
End Sub
The Paint event of the Canvas uses Graphics.DrawPicture to image the passed page.
Sub Paint(g As Graphics)
If mCurrentPicture <> Nil Then
g.DrawPicture(mCurrentPicture, 0, 0, Me.Width, Me.Height, 0, _
Scrollbar1.Value, Me.Width, Me.Height)
Else
g.DrawRectangle(0, 0, Me.Width, Me.Height)
End If
End Sub
Compatibility
All projects types on all supported operating systems.
See also
Object parent class; Reports Module module; Report class; Displaying Reports topic