private void btnPrintLook_Click(object sender, EventArgs e)
        {
        PrintDocument document=new PrintDocument();
        printLook.Document = this.printDoc;
        printLook.ShowDialog();
        }
这是我的代码,在打印预览时,只有空白文档,不知为什么?
还有就是怎样在打印中导入文件(用代码)及打印当前页?请教大家;
            

解决方案 »

  1.   

      private void button1_Click(object sender, EventArgs e)
            {            
                PrintDocument document = new PrintDocument();
                document.PrintPage += new PrintPageEventHandler(document_PrintPage);
               
                printLook.Document = document;
                printLook.ShowDialog();                     
            }        void document_PrintPage(object sender, PrintPageEventArgs e)
            {
                e.Graphics.DrawString("aaaaaaaaaaaa", new System.Drawing.Font("黑体",40), Brushes.Red, 0, 0);
            }这样用的.
      

  2.   

    是预览出问题了,是我没有说清楚,“aaaaaaaaaa”是什么?
      

  3.   

    1楼正解
    document上的内容是要自己填充的他的aaaaaaaaaaaa就是说在0,0的位置上用40的黑体写了一段字符串aaaaaaaaaaaa
      

  4.   

    所谓导入文件,就直接把内容放入document就行了吧
    - -
      

  5.   


    主要问题是预览框中出现的是空白的,没有aaaaaaaa或者任何字符,这是怎么回事
      

  6.   

    - -看不到图片……
    是wwinform么?using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Drawing.Printing;namespace CodeTest
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            PrintPreviewDialog printLook = new PrintPreviewDialog();
                    private void button1_Click(object sender, EventArgs e)
            {
                PrintDocument document = new PrintDocument();
                document.PrintPage += new PrintPageEventHandler(document_PrintPage);            printLook.Document = document;
                printLook.ShowDialog();
            }        void document_PrintPage(object sender, PrintPageEventArgs e)
            {
                e.Graphics.DrawString("aaaaaaaaaaaa", new System.Drawing.Font("黑体", 40), Brushes.Red, 0, 0);
            }     }
    }
    整段程序你试试
    不会是你类用错了吧?还是没开延迟打印服务?
      

  7.   

    PrintPreviewDialog or PrintDialog ?前面一个是预览 ……
    - -我只是说说,以前我犯过这个错误……
      

  8.   

    一楼讲的很清楚了,要自己画的,不是说你仍个doc过去,他就帮你做好了,程序怎么知道你的东西到底要怎样显示?
    用GDI+自己一个个画就行了。
      

  9.   

    --|||上午打了一段话 提交的时候发现公司网络出问题了orz
    正如14楼说的,是要自己画的=- =除非你原版就是用的office组件,他本身功能就能实现