标题:关于C#报表问题
取消只看楼主
C心情
Rank: 2
等 级:论坛游民
帖 子:90
专家分:74
注 册:2008-1-19
结帖率:60%
 问题点数:0 回复次数:0 
关于C#报表问题
请教关于C#报表的设计问题,我的代码如下,问题是现在无论加载多少数据(报表祥细信息)都只能打印或预览一页(A4),
要如何显示下页呢?,具体代码要写在哪里,如何写!请高手帮忙解答!谢谢
  private void toolStripButton1_Click(object sender, EventArgs e)//打印按钮的单击事件
        {
            //打印事件代码
            PrintDocument pd = new PrintDocument();
            PrintPreviewControl ppc = new PrintPreviewControl();
            ppc.Document = pd;
            PrintPreviewDialog ppd = new PrintPreviewDialog();
            ppd.Document = pd;
            pd.DefaultPageSettings.PaperSize = new PaperSize("A4", 827, 1169);//纸张设置为A4
            pd.DocumentName = "报表系统";
            pd.PrintPage+=new PrintPageEventHandler(pd_PrintPage);
            ppd.ShowDialog();
        }
        //打印函数
        private void pd_PrintPage(object sender, PrintPageEventArgs e)
        {
            string StrHeadText="商品信息表";
            Font font = new Font("宋体", 15, FontStyle.Regular);
            SolidBrush solidbrush=new SolidBrush(Color .Black);
            Rectangle rectangle=new Rectangle(400,30,827,20);
            //报表标头信息
            e.Graphics.DrawString(StrHeadText, font, solidbrush, rectangle);
            Rectangle rectangle1 = new Rectangle(30, 50, 827, 20);
            e.Graphics.DrawString("序号    商品名称      规格       生产企业 ", font, solidbrush, rectangle1);
            //报表详细信息,数据源来自dataGridView1,这里以循环的方式加载到报表中  
            int Row = 50;
            int endfor = dataGridView1.Rows.Count - 1;
            for (int i = 0; i <endfor; i++)
            {
                string textvar=i.ToString()+"  "+dataGridView1["药品名称", i].Value.ToString()+"   "+dataGridView1["规格", i].Value.ToString()+"   "+dataGridView1["生产企业", i].Value.ToString();
                Rectangle rectangle0 = new Rectangle(30, Row + 40, 827, 20);
                e.Graphics.DrawString(textvar, font, solidbrush, rectangle0);
                Row = Row + 40;
            }
            //页脚信息......
        }
搜索更多相关主题的帖子: ppc new 打印 ppd sender 
2008-02-27 14:21



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-201125-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.374443 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved