如何以编程方式打印报告而不是单击vb.net中的打印按钮 [英] how to print report programatically rather than clicking print button in vb.net

查看:73
本文介绍了如何以编程方式打印报告而不是单击vb.net中的打印按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在不显示报告的情况下打印报告。

在我的表单中,我有一个保存按钮。单击保存按钮时,数据库将在报告显示后进行更新。如果用户单击报告中的打印按钮,我只能打印报告。现在我需要打印报告而不单击报告中的打印按钮。

目前我正在使用Visual Studio 2012和VB.Net,我使用Microsoft提供的默认报告查看器。我不知道这是否是正确的打印方式,如果有任何替代方案可以解决这个问题,请告诉我。



目前用于打印的代码:

I need to print a report without showing report.
In my form I have a save button. While clicking the save button the database is updating after the report displays. I can only print the report if users click the print button in the report. Now I need to print the report without clicking the print button in the report.
Currently I'm using Visual Studio 2012 with VB.Net and I use the default report viewer provided by Microsoft. I don't know if this a right way to print or not, if there are any alternate solutions for this problem please let me know.

Code currently used for printing:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
   If MsgBox("need a Print ?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
      Me.tblpurchaseTableAdapter.Fill(Me.DsPurchase.tblpurchase, NUD.Value)
      Me.tblpurchasesplitTableAdapter.Fill(Me.DsPurchase.tblpurchasesplit, NUD.Value)
      Me.RptVwr.RefreshReport()
      RptVwr.Show()
   End If
End Sub

推荐答案

如果我理解正确,您目前只使用报告查看器及其打印按钮。所以现在你想打印而不必先在报告查看器中看到预览。这听起来像是一个非常常见的请求,您应该尝试搜索 google [ ^ ]首先。



这是我在谷歌搜索中发现的一篇MSDN文章,可能正是您所寻找的:

解决方法:打印无预览的本地报告 [ ^ ]
If I understand correctly, you are currently just using the report viewer and it's print button. So now you want to print without first having to see the preview in the report viewer. This sounds like a pretty common request, you should probably have tried to search google[^] first.

Here is an MSDN article that I found in the google search that might be exactly what you are looking for:
Walkthrough: Printing a Local Report without Preview[^]


这篇关于如何以编程方式打印报告而不是单击vb.net中的打印按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆