G
Guest
Hello Everyone,
I have to generate all the pages, because at run time we do not know which
records will be on each page since the report is databound, but how can I
send only selected pages to the printer?
Here are some snippets of code:
**************************************
Private Sub ReportDocument_BeginPrint(ByVal sender As Object, _
ByVal e As System.Drawing.Printing.PrintEventArgs) Handles
MyBase.BeginPrint
mPageNumber = 0
mRow = 0
If DataBound Then
'some code
End If
If DataBound And GroupBy <> "" Then
'some more code
End If
If mPreviewed Then
'mPreviewed is set to true after the preview generation
'I want to prevent showing the PrintDialog when generating the
preview
'let the user select a printer and number of copies
Dim prn As New PrintDialog
prn.AllowSomePages = True
prn.Document = Me
If prn.ShowDialog() = DialogResult.Cancel Then
e.Cancel = True
End If
End If
End Sub
Private Sub ReportDocument_PrintPage(ByVal sender As Object, _
ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles
MyBase.PrintPage
mPageNumber += 1
mFooterLineHeight = e.Graphics.MeasureString("Test",
FooterFont).Height
mPageBottom = e.MarginBounds.Bottom
mPageStart = e.MarginBounds.Left
mWIdx = e.MarginBounds.Width / CallingForm.ClientRectangle.Width
mHIdx = e.MarginBounds.Height / CallingForm.ClientRectangle.Height
' if we're generating page 1 raise the ReportBegin event
If mPageNumber = 1 Then
RaiseEvent ReportBeginA(Me, e)
End If
Try
' generate the page header/body/footer
GeneratePage(e)
Catch ex As Exception
MessageBox.Show(ex.Message & ControlChars.CrLf & ex.StackTrace)
End Try
' if there are no more pages to generate then raise
' the ReportEnd event
If Not e.HasMorePages Then
RaiseEvent ReportEndA(Me, e)
End If
End Sub
**************************************
Thank you,
I have to generate all the pages, because at run time we do not know which
records will be on each page since the report is databound, but how can I
send only selected pages to the printer?
Here are some snippets of code:
**************************************
Private Sub ReportDocument_BeginPrint(ByVal sender As Object, _
ByVal e As System.Drawing.Printing.PrintEventArgs) Handles
MyBase.BeginPrint
mPageNumber = 0
mRow = 0
If DataBound Then
'some code
End If
If DataBound And GroupBy <> "" Then
'some more code
End If
If mPreviewed Then
'mPreviewed is set to true after the preview generation
'I want to prevent showing the PrintDialog when generating the
preview
'let the user select a printer and number of copies
Dim prn As New PrintDialog
prn.AllowSomePages = True
prn.Document = Me
If prn.ShowDialog() = DialogResult.Cancel Then
e.Cancel = True
End If
End If
End Sub
Private Sub ReportDocument_PrintPage(ByVal sender As Object, _
ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles
MyBase.PrintPage
mPageNumber += 1
mFooterLineHeight = e.Graphics.MeasureString("Test",
FooterFont).Height
mPageBottom = e.MarginBounds.Bottom
mPageStart = e.MarginBounds.Left
mWIdx = e.MarginBounds.Width / CallingForm.ClientRectangle.Width
mHIdx = e.MarginBounds.Height / CallingForm.ClientRectangle.Height
' if we're generating page 1 raise the ReportBegin event
If mPageNumber = 1 Then
RaiseEvent ReportBeginA(Me, e)
End If
Try
' generate the page header/body/footer
GeneratePage(e)
Catch ex As Exception
MessageBox.Show(ex.Message & ControlChars.CrLf & ex.StackTrace)
End Try
' if there are no more pages to generate then raise
' the ReportEnd event
If Not e.HasMorePages Then
RaiseEvent ReportEndA(Me, e)
End If
End Sub
**************************************
Thank you,