Printpreview控制器不显示该文件

时间:2015-01-09 04:56:08

标签: c# print-preview

我有以下代码

fName =E:\Csharp\NewMacaron\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\\data00.txt"

从我的程序中的一个方法,我创建了一个数据集,如上面的fName

,在应用程序文件夹中

在打印完印刷表格后,我在屏幕上显示了printController预览,其中包含Previous Next和其他一些用于打印和缩放的按钮。

form_load我有ShowPage();

PrintPageEventHandler不起作用,不显示任何内容。

但是,当我点击print_button正确的页面打印时:

printpreviewcontroller有什么问题?

我正在使用.net 3.5和c#2008

    private void ShowPage()
    {
        try
        {
            streamToPrint = new StreamReader(fName, Encoding.UTF8);
            pd = new PrintDocument();
            pd.DocumentName = fName;
            PrinterSettings ps = new PrinterSettings();
            printFont = new Font("Courier", 10);
            pd.PrinterSettings.PrinterName = prnName;     // GetDefaultPrinter returns prName
            pd.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("PaperA4", 840, 1180);
            ppc = new PrintPreviewControl();
            ppc.Document = pd;
            pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
        }
        catch (Exception es)
        {
            MessageBox.Show(es.Message.ToString());
        }
    }


    private void print_button(object sender, EventArgs e)
    {
        streamToPrint = new StreamReader(fName, Encoding.UTF8);
        pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
        try
        {
            pd.Print();
        }
        catch (Win32Exception es)
        {
            MessageBox.Show(es.Message.ToString());
            streamToPrint.Close();
        }
        streamToPrint.Close();
        PublicVariables.PrintFormStat = false;
        PublicVariables.PrintData = 0;
        this.Hide();

我在程序中有一个CRIMINAL BUG,printform被命名为ppc和printpreviewcontroller。

我不知道集会是如何接受的。

修正后的tI只能使用一次printpreviewcontroller

不显示第二页。

0 个答案:

没有答案