【问题标题】:How to know DialogResult with ReportViewer.PrintDialog()如何使用 ReportViewer.PrintDialog() 了解 DialogResult
【发布时间】:2012-03-30 01:00:55
【问题描述】:

我在互联网上遇到过很多次这个问题,但没有找到解决这个问题的好方法。

我想要的是从 ReportViewer 控件打印一份报告,如果它已被打印,我需要更改数据库中的一些内容(例如打印的用户、打印报告的时间)。

现在我使用了reportViewer.PrintDialog() 方法(打印效果很好),但我无法确定用户是否实际打印了文档,或者取消了打印对话框。

我还尝试了返回 DialogResult 的 System.Windows.Controls.PrintDialog(),但我找不到将 reportViewer 的报告设置为 PrintDocument 的源的方法。

你们中有人找到方法了吗?

提前致谢,如果需要,可以提供更多信息/代码。

【问题讨论】:

  • 如果您的意思是物理打印出来,那么就没有明智的做法。我见过的最近的事情是要求打印带有某种作业条形码的打印件,然后通过扫描所述条形码确认打印件的生产。
  • 我的意思是如果用户点击了PrintDialog中的“打印”按钮或“取消”按钮,标题确实有点误导,我改一下。

标签: printing report reportviewer printdialog


【解决方案1】:

如果是 C#

对话框返回一个DialogResult类型的值

类似

if (System.Windows.Controls.PrintDialog().ShowDialog() == DialogResult.OK)
{
// Mark item as Prionted by User U
}

【讨论】:

    【解决方案2】:

    在 VB.NET 中,尝试以下操作:

    If reportViewer.PrintDialog() = Windows.Forms.DialogResult.OK Then
     'Put your stuff here
    End If
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-10
      • 2013-05-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-30
      • 1970-01-01
      • 2019-03-22
      相关资源
      最近更新 更多