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 PrintPreviewCon trol already has events, and
you should be able to capture them inherently.
On your form, click on the PrintPreviewCon trol
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(ByV al sender As System.Object, _
ByVal e As System.EventArg s) Handles PrintToolStripB utton.Click,
PrintToolStripM enuItem.Click
'This calls PrintPage for each page in ProductPrintDoc ument
'so that means it ends up calling ProductPrintDoc ument_PrintPage
' because that handles the ProductPrintDoc ument.PrintPage event.
' page in ProductPrintDoc ument.
ProductPrintDoc ument.Print()
End Sub
Private Sub PrintPreviewBut ton(ByVal sender As System.Object, _
ByVal e As System.EventArg s) _
Handles PrintPreviewToo lStripButton.Cl ick, _
PrintPreviewToo lStripMenuItem. Click
ProductPrintPre view.Document = ProductPrintDoc ument
'this shows the document in PrintPreview mode
'the user can print it from there or cancel
ProductPrintPre view.ShowDialog ()
End Sub
Private Sub ProductPrintDoc ument_PrintPage (ByVal sender As Object, _
ByVal e As System.Drawing. Printing.PrintP ageEventArgs) _
Handles ProductPrintDoc ument.PrintPage
Try
ProcessPrintPag e(sender, e)
Catch ex As InvalidOperatio nException
MessageBox.Show (My.Resources.P rintErrActiveFo rm)
End Try
End Sub
Robin S.
------------------------------------------
"Stuart Nathan" <st***********@ homecall.co.ukw rote in message
news:%2******** *******@TK2MSFT NGP02.phx.gbl.. .
No.
I created it using
Dim WithEvents Preview as PrintPreviewCon trol
I have tried a standard Dim statement and then adding an AddHandlern but
no difference there.
I do the "printing" in the PrintPage event, but this event is not raised
again even if I change the PrintPreview.Do cument