关于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;
}
//页脚信息......
}