I'm on event expert, but here's what I think.
If you dim something WithEvents, you can raise
events and capture events on it. Are you doing
that?
The PrintPreviewControl already has events, and
you should be able to capture them inherently.
On your form, click on the PrintPreviewControl
and look at the properties. If you click on the
lightning bolt, it will show you the addressable
events. Although, I don't know why you would
need to do this.
Here is the code I'm using for my PrintPreview
and Print buttons. My PrintPage event is below also.
Will this work for you?
Private Sub PrintButton(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles PrintToolStripButton.Click,
PrintToolStripMenuItem.Click
'This calls PrintPage for each page in ProductPrintDocument
'so that means it ends up calling ProductPrintDocument_PrintPage
' because that handles the ProductPrintDocument.PrintPage event.
' page in ProductPrintDocument.
ProductPrintDocument.Print()
End Sub
Private Sub PrintPreviewButton(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles PrintPreviewToolStripButton.Click, _
PrintPreviewToolStripMenuItem.Click
ProductPrintPreview.Document = ProductPrintDocument
'this shows the document in PrintPreview mode
'the user can print it from there or cancel
ProductPrintPreview.ShowDialog()
End Sub
Private Sub ProductPrintDocument_PrintPage(ByVal sender As Object, _
ByVal e As System.Drawing.Printing.PrintPageEventArgs) _
Handles ProductPrintDocument.PrintPage
Try
ProcessPrintPage(sender, e)
Catch ex As InvalidOperationException
MessageBox.Show(My.Resources.PrintErrActiveForm)
End Try
End Sub
Robin S.