I use something like the following code to close a StiViewerForm automatically after printing (VB.NET):
Code: Select all
Private stiVewForm As New Stimulsoft.Report.Viewer.StiViewerForm
Private Sub ButtonShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonShow.Click
Dim report As StiReport
report = StiReport.GetReportFromAssembly("myreport.dll", True)
AddHandler report.CompiledReport.Printed, AddressOf report_Printing ' !! <- This doesn't work as report.CompiledReport is Nothing
report.Render()
stiVewForm.Report = report
stiVewForm.Show()
End Sub
Private Sub report_Printing(ByVal sender As Object, ByVal e As EventArgs)
Dim report As StiReport = TryCast(sender, StiReport)
If (report.PrinterSettings.PrintDialogResult = DialogResult.OK) Then
MessageBox.Show("Printing")
End If
stiVewForm.Close()
End Sub
Is there any other way to use the printed event of a report loaded from an assembly to automatically close the viewer form?
Thank you in advance.
Best Regards,
Thomas