假设第一页打印出一个黑色矩形
第二页打印出一个红色举行我只能打印出第一页,第二页不止到如何处理以下为我的代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace 打印测试
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
           //第一页的矩形
            e.Graphics.DrawRectangle(new Pen(Brushes.Black), new Rectangle(0, 0, 200, 200));
           //第二页的矩形
            e.Graphics.DrawRectangle(new Pen(Brushes.Bisque), new Rectangle(0, 0, 400, 400));
        }        private void button1_Click(object sender, EventArgs e)
        {
            this.printPreviewDialog1.ShowDialog();
        }
    }
}

解决方案 »

  1.   

    当然不能这样了。
    要是这样我还不如自动建立printDocuments
      

  2.   

    http://www.wave12.com/web/SigCon.asp?bCate=50&sCateName=%B9%A6%C4%DC%BD%E9%C9%DC&ID=173&CateName=wsReport4.6
      

  3.   

    private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
            {
               //第一页的矩形
                e.Graphics.DrawRectangle(new Pen(Brushes.Black), new Rectangle(0, 0, 200, 200));
               e.HasMorePage=true;//分页
               //第二页的矩形
                e.Graphics.DrawRectangle(new Pen(Brushes.Bisque), new Rectangle(0, 0, 400, 400));
            }
    www.WebMIS.com.cn有分页原理与实现的文档与源码www.AnyReport.Net套打
      

  4.   

    刚刚找到解决方案。
    尝试一下吧。namespace 打印测试
    {
        public partial class Form1 : Form
        {
            int pageCount=0;
            public Form1()
            {
                InitializeComponent();
            }        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
            {
               if(pageCount==0)
               {
                  //第一页的矩形
                e.Graphics.DrawRectangle(new Pen(Brushes.Black), new Rectangle(0, 0, 200, 200));
                pageCount++;
                e.HasMorePages = true;
                return;
                }
                if(pageCount==1)
                {
                          //第二页的矩形
                e.Graphics.DrawRectangle(new Pen(Brushes.Bisque), new Rectangle(0, 0, 400, 400));
                 pageCount=0;
                 e.HasMorePages = false;
                 return;
                 }
            }        private void button1_Click(object sender, EventArgs e)
            {
                this.printPreviewDialog1.ShowDialog();
            }
        }
    }呵呵,刚解决的!