本文介绍了在.net中的WinForms使用打印preVIEW的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写C#code在.net 2008年的WinForms。

I am writing c# code in .Net 2008 Winforms.

我创建了一个打印preVIEW窗口创建一个报表。它工作正常,我可以preVIEW报告,然后打印出来。唯一的问题是它不够灵活的办公打印preVIEW。用户不能选择其它的默认打印机的打印机,他们不能限制打印某些网页。也许我缺少了一些性质鉴别仪表,我所需要的。

I created a print preview window to create a report. It works fine I can preview the report and then print it. The only problem is it is not as flexible as the Office Print preview. The users cannot chose a printer other that the default printer and they cannot limit the print to certain pages. Perhaps I am missing some prperties I need.

这里是code我用的部分内容:

Here is a portion of the code I use:

PrintDocument pd = new PrintDocument();
            pd.PrintPage += new PrintPageEventHandler(this.PrintTheGraph);
            pd.DefaultPageSettings.Landscape = true;
            // Allocate a print preview dialog object.
            PrintPreviewDialog dlg = new PrintPreviewDialog();
            dlg.Width = 100;
            dlg.MinimumSize = new Size(375, 250);
            dlg.SetBounds(100, -550, 800, 800);
            dlg.Document = pd;
            DialogResult result = dlg.ShowDialog();

谢谢

鲍勃·

推荐答案

打印preVIEW和打印有不同的功能,应该是不同的菜单选项。选择打印preVIEW不能打印文档,这是完全可能的是,用户希望看到自己的文件看起来像奠定了一个网页,而无需实际打印出来。

Print Preview and Print are different functions and should be different menu options. Choosing Print Preview should not print your document, it is entirely likely that a user would want to see what their document looks like laid out on a page without actually printing it.

要打印页面,并允许您选择打印机设备,使用:

To print a page and allow selecting printer devices, use :

PrintDialog pDialog = new PrintDialog( );
pDialog.Document = printDocument;
if (pDialog.ShowDialog( ) == DialogResult.OK) {
    printDocument.DocumentName = fileName;
    printDocument.Print( );
    }

PrintDialog类类有一个 UseEXDialog 属性,你可以用它来显示与打印选择扩展页面设置对话框,范围,N-up打印等。人。处理所有这些选项被大量的工作,GET PrintDialog类工作的第一位。

The PrintDialog class has a UseEXDialog property you can use to show an expanded Page Setup dialog with print selections, ranges, n-up printing, et. al. Handling all these options is a lot of work, get PrintDialog working first.

这篇关于在.net中的WinForms使用打印preVIEW的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 01:06