winform 打印控件

打印控件执行前需先创建打印对象

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();
            }
        }
复制代码
posted @ 2017-06-07 14:17  恶耀恢宏  阅读(3132)  评论(0编辑  收藏  举报