日期:2014-05-17 浏览次数:20905 次
private void Form1_Load(object sender, EventArgs e)
{
printPreviewDialog1.Document = printDocument1;
printPreviewDialog1.ShowDialog();
}
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
ArrayList a1 = new ArrayList();
for (int index = 0; index < 50; index++)
{
a1.Add(index+"");
}
for (int i = 0; i < a1.Count; i++)
{
//假设打印出来的东西是150 * 240
int x = (e.PageBounds.Width - 150) / 2;
int y = (e.PageBounds.Height - 240) / 2;
Font font = new Font("宋体", 14);
Brush bru = Brushes.Black;
e.Graphics.DrawString(a1[i].ToString(), font, bru, 40 * (i % 5) + x, 30 * (i / 5) + y);
}
}