标签:ptr handle initial 面向对象 form black user using dbr
printDocument 设置打印对象的各项初始属性,需要首先设置,面向对象的操作
打印控件分三步
1、打印页面设置 pageSetupDialog
2、打印预览 printPreviewControl 打印预览控件,不经常用
printPreviewDialog 打印预览对话框,常用
3、打印 printDialog
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace dayyin { public partial class Form1 : Form { //打印步骤 //打印设置 //打印预览 //打印 public Form1() { InitializeComponent(); } private void 页面设置ToolStripMenuItem_Click(object sender, EventArgs e) { pageSetupDialog1.Document = printDocument1;//将打印设置的指向打印对象1 pageSetupDialog1.ShowDialog();//弹出打印设置对话框 } private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { //首先要设置打印对象,类似于画板 Font f=new Font("宋体",14);//设置字体 Brush b=new SolidBrush(Color.Black);//设置画刷样式 PointF p = new PointF(10,10);//定义坐标点 e.Graphics.DrawString(textBox1.Text,f,b,p);//设置绘画参数,要绘制的字符串,字体,格式刷,坐标 //System.Drawing.Printing 命名空间提供与打印相关的服务。 //PrintPageEventArgs为 PrintPage 事件提供数据。 //Graphics 图形,图形,显卡 //DrawString 绘制字符串形式 } private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { } private void 打印预览VToolStripMenuItem_Click(object sender, EventArgs e) { //printPreviewControl1.Document = printDocument1;//打印预览控件 printPreviewDialog1.Document = printDocument1;//打印对话框 printPreviewDialog1.ShowDialog(); } private void 打印PToolStripMenuItem_Click(object sender, EventArgs e) { printDialog1.Document = printDocument1;//指向打印内容 printDialog1.ShowDialog();//显示打印对话框 } } }
标签:ptr handle initial 面向对象 form black user using dbr
原文地址:http://www.cnblogs.com/1030351096zzz/p/6160415.html