Выберите имя принтера, не показывая PrintDialog - PullRequest
0 голосов
/ 08 февраля 2019

У меня есть этот код.Когда мне нужно распечатать мой отчет, он показывает мне диалог печати.Я хочу выбрать имя для печати по коду и распечатать отчет без отображения PrintDialog.

Это мой код.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Printing;

namespace POS.Reports
{
public partial class ProductsReceiptPreview : Form
{
    BindingSource _data;
    string _total, _cashr, _cashc;
    public ProductsReceiptPreview(BindingSource data, string total, 
string cashr, string cashc)
    {
        InitializeComponent();
        _total = total; _cashr = cashr; _cashc = cashc;
        _data = data;
    }

    private void ProductsReceipt_Load(object sender, EventArgs e)
    {
        DataReceiptBindingSource.DataSource = _data;
        Microsoft.Reporting.WinForms.ReportParameter[] param = new 
        Microsoft.Reporting.WinForms.ReportParameter[]
        {
           new Microsoft.Reporting.WinForms.ReportParameter("ptotal", 
    _total),
            new Microsoft.Reporting.WinForms.ReportParameter("pcashr", 
    _cashr),
             new Microsoft.Reporting.WinForms.ReportParameter("pcashc", 
    _cashc),
            new Microsoft.Reporting.WinForms.ReportParameter
    ("pdate",DateTime.Now.ToString())
        };
        this.rptProductsReceipt.LocalReport.SetParameters(param);
        this.rptProductsReceipt.RefreshReport();
        this.rptProductsReceipt.ZoomMode = 
    Microsoft.Reporting.WinForms.ZoomMode.PageWidth;
    }


    private void btnReports_Click(object sender, EventArgs e)
    {
        rptProductsReceipt.PrintDialog();
    }

}
}

1 Ответ

0 голосов
/ 08 февраля 2019

Я никогда не использую ваш метод, но я использую это

rptProductsReceipt.PrintToPrinter(1, false, 0, 0);

после использования адаптера и таблицы данных

...