2009-05-29 1 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 возвращает отмену? Как узнать, был ли пользователь напечатан? Я хотел бы очистить очередь печати элементов, если они действительно печатали на принтер, или спросить их, должен ли я очистить его, но только если они действительно что-то напечатали.Как я могу узнать, напечатан ли кто-либо из 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 

 Смежные вопросы

  • Нет связанных вопросов^_^