直接打印报告,无需打印对话框和报告查看器 [英] Print report directly, without print dialogue box and report viewer
问题描述
我需要将报告直接打印到打印机:
1)没有显示打印对话框
2)没有显示Reportviewer
我被建议使用以下代码:
< pre lang =vb> Dim printerSettings As New PrinterSettings()
Dim printDialog As 新 PrintDialog()
printDialog.PrinterSettings = printerSettings
printDialog.AllowPrintToFile = False
printDialog.AllowSomePages = < span class =code-keyword> True
printDialog.UseEXDialog = True
Dim 结果 As DialogResult = printDialog.ShowDi alog()
如果 result = DialogResult.Cancel 那么
返回
结束 如果
我 .rptSalesReport.PrintOptions.PrinterName = printerSettings.PrinterName
Me .rptSalesReport.PrintToPrinter(printerSettings.Copies, False , 0 , 0 )
但我在最后两行收到错误,我把报告的名字写在,
rptSalesReport。它说:
rptSalesReport 不定义。
虽然我的项目中有rptSalesReport,但我可以通过报告查看器查看。
请指教。
谢谢
Hi,
I need to print my reports directly to printer:
1) Without showing print dialogue box
2) Without showing the Reportviewer
I was suggested the following code:
Dim printerSettings As New PrinterSettings()
Dim printDialog As New PrintDialog()
printDialog.PrinterSettings = printerSettings
printDialog.AllowPrintToFile = False
printDialog.AllowSomePages = True
printDialog.UseEXDialog = True
Dim result As DialogResult = printDialog.ShowDialog()
If result = DialogResult.Cancel Then
Return
End If
Me.rptSalesReport.PrintOptions.PrinterName = printerSettings.PrinterName
Me.rptSalesReport.PrintToPrinter(printerSettings.Copies, False, 0, 0)
But I am receiving error on the last two lines, where I put the name of my reports,
rptSalesReport. It says:
rptSalesReport is not defined.
While the rptSalesReport is there in my project and I can view it through report viewer.
Please advise.
Thanks
这篇关于直接打印报告,无需打印对话框和报告查看器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!