打印控件执行前需先创建打印对象
1、PrintDocument:打印对象
(1)、构造函数初始打印对象
pageSetupDialog1.Document = printDocument1;
(2)、创建打印对象内容
2、PageSetupDialog:打印页面设置
private void 页面设置ToolStripMenuItem_Click(object sender, EventArgs e)
{
pageSetupDialog1.Document = printDocument1;
DialogResult dr = pageSetupDialog1.ShowDialog();
if (dr == DialogResult.OK)
{ }
}
3、PrintPreviewDialog:打印预览
4、PrintPreviewControl:页面显示打印预览
private void 打印预览VToolStripMenuItem_Click(object sender, EventArgs e)
{
printPreviewControl1.Document =printDocument1;
printPreviewDialog1.Document = printDocument1;
DialogResult dr = printPreviewDialog1.ShowDialog();
if(dr==DialogResult.OK)
{}
}
5、PrintDialog:打印
private void 打印PToolStripMenuItem_Click(object sender, EventArgs e)
{
printDialog1.Document = printDocument1;
DialogResult dr = printDialog1.ShowDialog();
if(dr==DialogResult.OK)
{
printDocument1.Print();
}
}