【问题标题】:Printing localReport with only printer selection in C#在 C# 中仅使用打印机选择打印 localReport
【发布时间】:2011-08-12 15:24:43
【问题描述】:

如何打印没有预览但带有打印机选择窗口的 LocalReport?

谢谢。

【问题讨论】:

  • @martin,感谢您的帮助。

标签: c# .net reporting reportviewer localreport


【解决方案1】:

您可以使用打印机选项制作自己的表单。使用System.Drawing.Printing.PrinterSettings 类将已安装的打印机绑定到组合框或其他东西

    foreach (string s in PrinterSettings.InstalledPrinters)
    {
      liste.Items.Add(s);
    }

然后您可以使用此代码创建报告(确保您的报告构建操作设置为嵌入资源)

LocalReport report = new LocalReport();
report.DataSources.Add(new ReportDataSource("your data source name",DataTableGoesHere);
        report.ReportEmbeddedResource = "YourNameSpace.YourReportName.rdlc";

然后按照此处的说明打印本地报告: http://blogs.msdn.com/b/brianhartman/archive/2009/02/27/manually-printing-a-report.aspx

确保您以某种方式将要使用的打印机变量传递给打印类。必须设置打印机名称:

printDoc.PrinterSettings.PrinterName = "installed printer chosen from combo goes here"; 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-08
    • 2010-12-10
    • 2017-11-26
    • 1970-01-01
    相关资源
    最近更新 更多