6.30 winform 打印

 1 using System;
 2 using System.Collections.Generic;
 3 using System.ComponentModel;
 4 using System.Data;
 5 using System.Drawing;
 6 using System.Linq;
 7 using System.Text;
 8 using System.Windows.Forms;
 9 
10 namespace _6._30_下午打印
11 {
12     public partial class Form1 : Form
13     {
14         public Form1()
15         {
16             InitializeComponent();
17         }
18 
19         private void Form1_Load(object sender, EventArgs e)
20         {
21 
22         }
23       //页面设置
24         private void 打印设置ToolStripMenuItem_Click(object sender, EventArgs e)
25         {
26             pageSetupDialog1.Document = printDocument1;
27             pageSetupDialog1.ShowDialog();
28    
29         }
30 
31         private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
32         {
33      
34             Font f=new Font("楷体",14);//字体
35             Brush b=new SolidBrush(Color.Black);  //画刷
36             PointF p=new PointF(10,10);//定义位置具有XY轴,(10,10)左+上
37             e.Graphics.DrawString(textBox1.Text, f, b, p);//格式刷
38         }
39 
40 
41         //打印预览
42         private void 打印预览VToolStripMenuItem_Click(object sender, EventArgs e)
43         {
44        
45          // printPreviewControl1.Document = printDocument1;
46             printPreviewDialog1.Document = printDocument1;
47             printPreviewDialog1.ShowDialog();
48             
49 
50         }
51 
52         //打印
53 
54         private void 打印PToolStripMenuItem_Click(object sender, EventArgs e)
55         {
56             printPreviewDialog1.Document = printDocument1;
57             printDialog1.ShowDialog(); 
58             //打印步骤:(1)页面设置(2)打印预览(3)打印
59         }
60 
61     }
62 }

 

posted @ 2016-06-30 22:47  一人饮酒醉(SeVen❤)  阅读(168)  评论(0编辑  收藏  举报