而不显示PrintDialog类选择打印机名称

问题描述 投票:0回答:1

我有这样的代码。当我需要打印报告,它显示我的打印对话框。我想通过代码来选择我打印的名字,并打印我的报告没有显示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();
    }

}
}
c# printing report
1个回答
0
投票

我从来没有使用你的方法,但我用这个

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

使用适配器和数据表后

© www.soinside.com 2019 - 2024. All rights reserved.