如何使用c#.net在打印对话框中禁用no.of copies选项 [英] how to disable no.of copies option in print dialog box using c#.net

查看:444
本文介绍了如何使用c#.net在打印对话框中禁用no.of copies选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在设计一个用于报告的窗口应用程序,但我们无法处理打印对话框中的份数选项。



我想用rdlc打印报告Microsoft报告工具:

We are design a window application for reporting but we can't handle number of copies option in print dialog box.

I want to print a report with rdlc Microsoft reporting tool:

reportviwer1.printdialog();





I想要处理没有副本(一次一个副本命令)



I want to handle no of copies ( one copies at a time command )

推荐答案

看看这个解决方案:更改PrintDialog框中显示的副本数量 [ ^ ]:



Take a look at this solution: Change number of copies displayed in PrintDialog box[^] :

.Net Framework doesn't provide any mechanism to override the default print functionality. So I disabled the default print button, and added a button name Print.Code for the Event Handler follows below.







private void Print_Click(object sender, EventArgs e)
{
    try
    {
        PrintDialog printDialog1 = new PrintDialog();
        PrintDocument pd = new PrintDocument();

        printDialog1.Document = pd;
        printDialog1.ShowNetwork = true;
        printDialog1.AllowSomePages = true;
        printDialog1.AllowSelection = false;
        printDialog1.AllowCurrentPage = false;
        printDialog1.PrinterSettings.Copies = (short)this.CopiesToPrint;
        printDialog1.PrinterSettings.PrinterName = this.PrinterToPrint;
        DialogResult result = printDialog1.ShowDialog();
        if (result == DialogResult.OK)
        {
            PrintReport(pd);
        }
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

private void PrintReport(PrintDocument pd)
{
    ReportDocument rDoc=(ReportDocument)crvReport.ReportSource;
    // This line helps, in case user selects a different printer 
    // other than the default selected.
    rDoc.PrintOptions.PrinterName = pd.PrinterSettings.PrinterName; 
    // In place of Frompage and ToPage put 0,0 to print all pages,
    // however in that case user wont be able to choose selection.
    rDoc.PrintToPrinter(pd.PrinterSettings.Copies, false, pd.PrinterSettings.FromPage,
       pd.PrinterSettings.ToPage); 
}


这篇关于如何使用c#.net在打印对话框中禁用no.of copies选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆