2009-05-29 49 views
1
Using printPreview As New PrintPreviewDialog() 
     ' Dim x As New Printing.PrintDocument() 
     ' AddHandler x.PrintPage, AddressOf PrintData 
     printPreview.Document = Me.CurrentDocument 
     If ShowPrinterSetup Then 
      Dim x As New PrintDialog() 
      x.Document = CurrentDocument 
      x.ShowDialog(Anchor) 
     End If 
     whichPage = 0 
     Return printPreview.ShowDialog(Anchor) 
End Using 

到目前爲止,無論我在printpreview中點擊了什麼,showdialog都會返回cancel? 如何判斷用戶是否打印?我想清除物品的打印隊列,如果他們確實打印到打印機,或者詢問他們是否應該清除它,但只有在他們確實打印了某些東西時纔打印出來。如何判斷是否有人從printPreview打印?

回答

0

你可以從CurrentDocument EndPrint事件的打印作業的結果

Private WithEvents CurrentDocument As New PrintDocument 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 
    Using printPreview As New PrintPreviewDialog() 
     printPreview.Document = Me.CurrentDocument 
     printPreview.ShowDialog() 
    End Using 
End Sub 

Private Sub document_EndPrint(ByVal sender As Object, ByVal e As PrintEventArgs) Handles CurrentDocument.EndPrint 
    If e.PrintAction = PrintAction.PrintToPrinter Then 
     MsgBox("Document Printed to Printer") 
    End If 
End Sub 
相關問題