码迷,mamicode.com
首页 > Windows程序 > 详细

6.30 winform 打印

时间:2016-06-30 23:24:21      阅读:228      评论:0      收藏:0      [点我收藏+]

标签:

 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 }

 

6.30 winform 打印

标签:

原文地址:http://www.cnblogs.com/suiyuejinghao123/p/5631494.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!