winform 打印控件

(1)PageSetupDialog1    打印设置窗口 

(2)PrintDocument     向打印机输送的对象

事件:PrintPage   对于打印的每一页都执行一次

(3)PrintPreviewControl     打印预览,在本窗口中预览,不包含任何对话框和按钮

 

(4)PrintPreviewDialog     打印预览,弹出一个预览窗口

(5)PrintDialog     打印   弹出打印窗口可选择打印机和任何打印项设置

 

//对于打印的每一页都执行一次
        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            Font f = new Font("微软雅黑",15);//字体
            Brush br = new SolidBrush(Color.Black);//画刷
            //绘制字符串,字体,画刷,左边距,上边距
            e.Graphics.DrawString(richTextBox1.Text,f,br,10,20);
        }
        //打印设置
        private void button1_Click(object sender, EventArgs e)
        {
            pageSetupDialog1.Document = printDocument1;//获取页面设置的printDocument(向打印机输送的对象)
            pageSetupDialog1.ShowDialog();
        }
        //打印预览
        private void button2_Click(object sender, EventArgs e)
        {
            printPreviewControl1.Document = printDocument1;//页面中预览
            printPreviewDialog1.Document = printDocument1;//弹出预览框
            printPreviewDialog1.ShowDialog();
        }
        //打印
        private void button3_Click(object sender, EventArgs e)
        {
            printDialog1.Document = printDocument1;//打印对象
            printDialog1.ShowDialog();
        }

 

posted @ 2016-12-11 16:52  浆糊033  阅读(822)  评论(0编辑  收藏  举报