How to directly print rdlc report without showing PrintDialog() in C#?

后端 未结 3 2051
星月不相逢
星月不相逢 2020-12-06 10:38

I have an application where I have to print a RDLC report without showing the printDialog and using the default specified printer defined in the application. Be

相关标签:
3条回答
  • 2020-12-06 11:06

    i have made an extension class to @tezzos answer. which might make it more easier.

    use this Gist Here to get the extension class i wrote. include it to your project. don't for get namespace :D

    LocalReport report = new LocalReport();
                report.ReportEmbeddedResource = "Your.Reports.Path.rdlc";
                report.DataSources.Add(new ReportDataSource("DataSet1", getYourDatasource()));
                report.PrintToPrinter();
    

    PrintToPrinter Method will be available on LocalReport. Might Help someone

    0 讨论(0)
  • 2020-12-06 11:15
    public void PrintSales(object sender, RenderingCompleteEventArgs e)
    {
        try
        {
            reportViewerSales.PageSetupDailog();
            reportViewerSales.PrintDialog();
            reportViewerSales.Clear();
            reportViewerSales.LocalReport.ReleaseSandboxAppDomain();
        }
        catch (Exception ex)
        {
        }
    }
    
    0 讨论(0)
  • 2020-12-06 11:16

    I just gave a quick look to a class I created to print directly and I think I took some ideas from this walkthrough: Printing a Local Report without Preview

    0 讨论(0)
提交回复
热议问题