I had the same problem as the code I use and it works like a charm!
using System; using System.IO; using System.Text; using System.Globalization; using System.Drawing; using System.Drawing.Imaging; using System.Drawing.Printing; using Microsoft.Reporting.WinForms; using System.Collections.Generic; using System.Collections.Specialized; using System.Diagnostics; using System.ComponentModel; using System.Data; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; namespace NewLabelPrinter {
}
This class has the perfect setting for what you need, but all you need to do is:
private void AutoPrint() { AutoPrintCls autoprintme = new AutoPrintCls(reportViewer1.LocalReport); autoprintme.Print(); }
and hey presto is typing. Just attach this to the method in your code (maybe after the report loads.) And your setup is beautiful!
: (not verified)
As indicated, this prints to the default printer, to change the printer, you can do the following:
if (printDialog.ShowDialog() == DialogResult.OK) { m_pageSettings .PrinterSettings.PrinterName = printDialog.PrinterSettings.PrinterName; }
not tested, although I no longer have the source code to test this.
source share