如何判断是否有人从printPreview打印出来?

时间:2009-05-29 14:07:05

标签: vb.net printing

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都会返回取消? 如何判断用户是否打印?我想清除项目的打印队列,如果他们确实打印到打印机或询问他们是否应该清除它,但只有当他们确实打印了一些东西时。

1 个答案:

答案 0 :(得分: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