项目打印输出表格图片及分页打印课件_第1页
项目打印输出表格图片及分页打印课件_第2页
项目打印输出表格图片及分页打印课件_第3页
项目打印输出表格图片及分页打印课件_第4页
项目打印输出表格图片及分页打印课件_第5页
已阅读5页,还剩22页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、项目六:打印输出项目六:打印输出主讲人:艾长春教学目的要求:教学目的要求:1、掌握、掌握PrintDocument类的对象的常用属性和类的对象的常用属性和方法、事件;方法、事件;2、掌握、掌握PrintPreviewDialog类的对象的常用属类的对象的常用属性和方法;性和方法;3、学会用、学会用Font类的对象定义。类的对象定义。4、掌握字符串对象、表格、图片的打印输出、掌握字符串对象、表格、图片的打印输出方法,学习分页打印。方法,学习分页打印。教学重点、难点:教学重点、难点:字符串的输出、图片的输出字符串的输出、图片的输出学而不思则罔,思而不学则殆学而不思则罔,思而不学则殆命名空间:usi

2、ng System.IO ;using System.Drawing.Printing;在类中创建对象:文档对象、预览对象、画笔对象、字体对象private System.Drawing.Printing.PrintDocument pd = new System.Drawing.Printing.PrintDocument();/创建打印文档private PrintPreviewDialog prv = new PrintPreviewDialog();/创建打印预览对话框private string prText =null ;/打印内容Brush br = Brushes.Red;/创

3、建红色画笔Font f= new Font(“Arial”, 30);/设置字体PointF pf = new PointF(140,140);/定义打印的起始位置建立打印事件:private void pd_PrintPage(object sender,PrintPageEventArgs ev)/建立打印控制事件 if (f = null & br = null)/如果没有设置打印字体和画笔就用10号字,黑色 ev.Graphics.DrawString(prText, new Font (Arial,10),Brushes .Black ,new PointF(ev.MarginBou

4、nds .Left ,ev.MarginBounds .Top ); else ev.Graphics.DrawString(prText, f, br, pf); 用打印机进行打印一行文字。用打印机进行打印一行文字。打印按钮代码: prText = tbx_prText.Text; PointF pf = new PointF(this .Width /2-20,this .Height /2-20);/定义打印的起始位置 if (prText.Length = 0) MessageBox.Show(没有打印内容!); return; pd.PrintPage +=new PrintPage

5、EventHandler(pd_PrintPage); pd.Print();/开始打印 打印预览按钮代码 prText = tbx_prText.Text; PointF pf = new PointF(this.Width / 2 - 20, this.Height / 2 - 20);/定义打印的起始位置 if (prText.Length = 0) MessageBox.Show(没有打印内容!); return; pd.PrintPage += new PrintPageEventHandler(pd_PrintPage); prv.Document = pd; prv.ShowDi

6、alog();PrintDocument类1、 PrintDocument对象常用的属性:对象常用的属性:DefultPageSettings属性:读写属性。这是页的设置用于要打属性:读写属性。这是页的设置用于要打印的所有页的默认设置。印的所有页的默认设置。DocumentName属性:读写属性。打印文档时要显示的文档属性:读写属性。打印文档时要显示的文档名(在打印状态对话框或打印队列中显示)。名(在打印状态对话框或打印队列中显示)。OriginAtMargins属性:读写属性。与面关联的图形对象的位属性:读写属性。与面关联的图形对象的位置是位于用户指定的边距内,还是位于该页打印区域的左上角。

7、置是位于用户指定的边距内,还是位于该页打印区域的左上角。PrintController属性:获取或设置打印进程的打印控制器。属性:获取或设置打印进程的打印控制器。PrintSettings属性:获取或设置对文档进行打印的打印机。属性:获取或设置对文档进行打印的打印机。2、PrintDocument的方法的方法Print():如果不需要预览或设置打印机,可以直接调用如果不需要预览或设置打印机,可以直接调用Print方方法进行打印。如:法进行打印。如:pd.Print();3、PrintDocument的事件的事件PrintPage:当需要打印当前页并输出时发生。只有设置了打:当需要打印当前页并输

8、出时发生。只有设置了打印内容后,才能打印输出。印内容后,才能打印输出。创建打印文档的方法:创建打印文档的方法:System.Drawing.Printing.PrintDocument pd = new System.Drawing.Printing.PrintDocument();声明打印文档的打印当前页事件:声明打印文档的打印当前页事件:pd.PrintPage +=new PrintPageEventHandler(pd_PrintPage);创建打印文档的打印页事件过程:创建打印文档的打印页事件过程:private void pd_PrintPage(object sender,Pri

9、ntPageEventArgs ev) 设置打印的内容;打印文档调用打印方法:打印文档调用打印方法:pd.Print();打印字符串的方法:打印字符串的方法:ev.Graphics.DrawString(字符串, 字体, 画刷, 打印起始点);字体设置格式:字体设置格式:Font f= new Font(“字体”, 字号,字型,单位);画刷的定义:画刷的定义:Brush br = Brushes.Red;PrintPreviewDialog类1、PrintPreviewDialog的属性Document:获取或设置预览的文档。如:prv.Documet=pd;Modal:是否有模式地显示上窗口

10、。2、打印位置如:ev.Graphics.DrawString(line, printFont, Brushes.Black, new PointF(ev.MarginBounds.Left, ev.MarginBounds.Top);用于调整位置的值: new PointF(ev.MarginBounds.Left, ev.MarginBounds.Top)设计用打印机打印表格。设计用打印机打印表格。命名空间:using System.Data.SqlClient;using System.Drawing .Printing ;using System.IO;定义类的成员变量:SqlConn

11、ection con = new SqlConnection(server=.;database=stuM;integrated security=true);DataTable dt = new DataTable();private Font printFont = null;/设置打印字体string couresName = “”;/打印的课程名int n = 0;/确定行数string className;/打印的班级名数组string RenShu;/打印的人 数数组string Sumf;/打印的班级总分string RenshuTotal;/汇总人合计string SumTot

12、al;/汇总总分合计窗体装入事件代码string sqlstr = select * from couresTab;SqlDataAdapter da = new SqlDataAdapter(sqlstr, con);DataTable dt = new DataTable();da.Fill(dt);cbx_KC.DataSource = dt;cbx_KC.DisplayMember = couresName;cbx_KC.ValueMember = couresId;cbx_KC.SelectedIndex = 0;组合框选择改变事件代码SqlCommand com = new Sql

13、Command(KCTJ,con);com.CommandType = CommandType.StoredProcedure;com.Parameters.Add(kcId, SqlDbType.NVarChar, 2).Value = cbx_KC.SelectedValue.ToString ();com.Parameters.Add(bjzs, SqlDbType.Int);com.Parameters1.Direction = ParameterDirection.Output;SqlDataAdapter da = new SqlDataAdapter(com);dt.Clear(

14、);da.Fill(dt);dataGridView1 .DataSource =dt;label3 .Text =班级总数:+com .Parametersbjzs.Value .ToString ();couresName = cbx_KC.Text; 打印按钮单击事件代码: n = dt.Rows.Count; className=new stringn;/班级名称 RenShu = new stringn;/考试人数 Sumf = new stringn;/总分 int RSTotal = 0;/人数合计 double SumfTotal = 0;/总分合计 for (int i=0;

15、in;i+) classNamei = dt.Rowsi0.ToString(); RenShui = dt.Rowsi1.ToString(); RSTotal = RSTotal + int.Parse (dt.Rowsi1.ToString (); Sumfi = dt.Rowsi2.ToString(); SumfTotal = SumfTotal + double.Parse(dt.Rowsi2.ToString(); RenshuTotal = RSTotal.ToString(); SumTotal = SumfTotal.ToString(); printFont = new

16、Font(Arial, 10); PrintDocument pd = new PrintDocument();/建立打印的文档 PaperSize ps = new PaperSize();/定义纸张的大小 ps.RawKind = 9;/8是A3纸,9是A4纸,10是A4小,11是A5,12是B4,13是B5,大于118是自定义纸张、可以定义纸张的宽度和高度。 /ps.Height = 370;/定义纸的高度 /ps.Width = 854;/定义纸的宽度 pd.DefaultPageSettings.PaperSize = ps; pd.DefaultPageSettings.Lands

17、cape = true;/控件打印纸的方向,True是横向打印,默认为false纵向打印。 pd.PrintPage +=new PrintPageEventHandler(pd_PrintPage);/调用打印事件 PageSetupDialog psd = new PageSetupDialog();/页面设置对话框 psd.ShowNetwork = false;/页面设置对话框的打印按钮对话框中的远程网络按钮是否可见 psd.PageSettings = new PageSettings();/用于单页打印的页设置 psd.ShowDialog(); pd.PrinterSetting

18、s = psd.PrinterSettings;/获取或设置与该页关联的打印机的设置 pd.DefaultPageSettings = psd.PageSettings; pd.Print(); 用制表符来画表格 private void pd_PrintPage(object sender, PrintPageEventArgs ev)/定义打印事件 /以下代码是用制表符打印表格,质量差,主要是制表符对不齐 Single linesPerPage = 0;/每一页的行数 Single yPos = 0; int count = 0; Single leftMargin =ev.MarginB

19、ounds .Left + 20;/左页边距 Single topMargin = ev .MarginBounds .Top -30;/上页边距 string line = null; linesPerPage = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics);/每一页的打印行数,为页的高度除以打印字体的高度 /打印第一行 line = 班级成绩统计; printFont = new Font(Arial, 30); yPos = topMargin + count * printFont.GetHeight(ev.Gra

20、phics); ev.Graphics.DrawString(line, printFont, Brushes.Blue , leftMargin+40, yPos, new StringFormat(); /打印第二行,打印课程名,打印日期 line = 课程名: + couresName + + System.DateTime.Now.ToString(); printFont = new Font(Arial, 10); count = count + 1; yPos = topMargin + count * printFont.GetHeight(ev.Graphics)+40; e

21、v.Graphics.DrawString(line, printFont, Brushes.Red, leftMargin, yPos, new StringFormat(); /打印第三行,主要是制表符 line = ; count = count + 1; yPos = topMargin + count * printFont.GetHeight(ev.Graphics)+40; ev.Graphics.DrawString(line, printFont, Brushes.Green , leftMargin, yPos, new StringFormat(); line = ; e

22、v.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin + 106, yPos, new StringFormat(); line = ; ev.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin + 212, yPos, new StringFormat(); line = ; ev.Graphics.DrawString(line, printFont, Brushes.Green , leftMargin+318, yPos, new Str

23、ingFormat(); line = ; ev.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin + 424, yPos, new StringFormat(); /打印第四行 count = count + 1; line = ; yPos = topMargin + count * printFont.GetHeight(ev.Graphics)+40; ev.Graphics.DrawString(line, printFont, Brushes.Green , leftMargin, yPos, new St

24、ringFormat(); line = 班级名称:; ev.Graphics.DrawString(line, printFont, Brushes.Green , leftMargin+20, yPos, new StringFormat(); line = ; ev.Graphics.DrawString(line, printFont, Brushes.Green , leftMargin+110, yPos, new StringFormat(); line = 人数; ev.Graphics.DrawString(line, printFont, Brushes.Green , l

25、eftMargin + 130, yPos, new StringFormat(); line = ; ev.Graphics.DrawString(line, printFont, Brushes.Green , leftMargin + 216, yPos, new StringFormat(); line = 总分; ev.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin + 238, yPos, new StringFormat(); line = ; ev.Graphics.DrawString(line,

26、printFont, Brushes.Green, leftMargin + 322, yPos, new StringFormat(); line = 备注; ev.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin + 346, yPos, new StringFormat(); line = ; ev.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin + 424, yPos, new StringFormat(); /打印第五行 count

27、 = count + 1; line = ; yPos = topMargin + count * printFont.GetHeight(ev.Graphics) + 40; ev.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin, yPos, new StringFormat(); line = ; ev.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin + 106, yPos, new StringFormat(); line = ; e

28、v.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin + 212, yPos, new StringFormat(); line = ; ev.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin + 318, yPos, new StringFormat(); line = ; ev.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin + 424, yPos, new St

29、ringFormat(); /第六行后,可能有多行 printFont = new Font(Arial, 10); for (int i = 0; i n; i+) count = count + 1; line = ; yPos = topMargin + count * printFont.GetHeight(ev.Graphics) + 40; ev.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin, yPos, new StringFormat(); line = className i; ev.Graphi

30、cs.DrawString(line, printFont, Brushes.Green, leftMargin + 20, yPos, new StringFormat(); line = ; ev.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin + 110, yPos, new StringFormat(); line = RenShu i; ev.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin + 130, yPos, new Str

31、ingFormat(); line = ; ev.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin + 216, yPos, new StringFormat(); line = Sumfi; ev.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin + 238, yPos, new StringFormat(); line = ; ev.Graphics.DrawString(line, printFont, Brushes.Green, le

32、ftMargin + 322, yPos, new StringFormat(); line = ; ev.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin + 424, yPos, new StringFormat(); count = count + 1; line = ; yPos = topMargin + count * printFont.GetHeight(ev.Graphics) + 40; ev.Graphics.DrawString(line, printFont, Brushes.Green, l

33、eftMargin, yPos, new StringFormat(); line = ; ev.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin + 106, yPos, new StringFormat(); line = ; ev.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin + 212, yPos, new StringFormat(); line = ; ev.Graphics.DrawString(line, printFont

34、, Brushes.Green, leftMargin + 318, yPos, new StringFormat(); line = ; ev.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin + 424, yPos, new StringFormat(); /表格的汇总行 count = count + 1; line = ; yPos = topMargin + count * printFont.GetHeight(ev.Graphics) + 40; ev.Graphics.DrawString(line,

35、printFont, Brushes.Green, leftMargin, yPos, new StringFormat(); line = 汇总; ev.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin + 20, yPos, new StringFormat(); line = ; ev.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin + 110, yPos, new StringFormat(); line = RenshuTotal.

36、ToString(); ev.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin + 130, yPos, new StringFormat(); line = ; ev.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin + 216, yPos, new StringFormat(); line = SumTotal.ToString(); ev.Graphics.DrawString(line, printFont, Brushes.Green

37、, leftMargin + 238, yPos, new StringFormat(); line = ; ev.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin + 322, yPos, new StringFormat(); line = ; ev.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin + 424, yPos, new StringFormat(); count = count + 1; line = ; yPos = top

38、Margin + count * printFont.GetHeight(ev.Graphics) + 40; ev.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin, yPos, new StringFormat(); line = ; ev.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin + 106, yPos, new StringFormat(); line = ; ev.Graphics.DrawString(line, print

39、Font, Brushes.Green, leftMargin + 212, yPos, new StringFormat(); line = ; ev.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin + 318, yPos, new StringFormat(); line = ; ev.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin + 424, yPos, new StringFormat(); line = null; /如果有更多

40、的行,打印另一些页 if (line != null) ev.HasMorePages = true; else ev.HasMorePages = false; 打印预览按钮代码: n = dt.Rows.Count; className = new stringn;/班级名称 RenShu = new stringn;/考试人数 Sumf = new stringn;/总分 int RSTotal = 0;/人数合计 double SumfTotal = 0;/总分合计 for (int i = 0; i n; i+) classNamei = dt.Rowsi0.ToString();

41、RenShui = dt.Rowsi1.ToString(); RSTotal = RSTotal + int.Parse(dt.Rowsi1.ToString(); Sumfi = dt.Rowsi2.ToString(); SumfTotal = SumfTotal + double.Parse(dt.Rowsi2.ToString(); RenshuTotal = RSTotal.ToString(); SumTotal = SumfTotal.ToString(); printFont = new Font(Arial, 10); PrintDocument pd = new Prin

42、tDocument();/建立打印的文档 pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);/调用打印事件 PageSetupDialog psd = new PageSetupDialog();/页面设置对话框 psd.ShowNetwork = false;/页面设置对话框的打印按钮对话框中的远程网络按钮是否可见 psd.PageSettings = new PageSettings();/用于单页打印的页设置 psd.ShowDialog(); pd.PrinterSettings = psd.PrinterSettings;

43、/获取或设置与该页关联的打印机的设置 pd.DefaultPageSettings = psd.PageSettings; PrintPreviewDialog prv = new PrintPreviewDialog();/预览对话框 prv.Document = pd; prv.ShowDialog(); 打印预览对象的创建:打印预览对象的创建:PrintPreviewDialog prv = new PrintPreviewDialog();预览的内容的建立:预览的内容的建立:prv.Document = pd;进行预览:进行预览:prv.ShowDialog();打印页面设置对话框的建

44、立:打印页面设置对话框的建立:PageSetupDialog ps = new PageSetupDialog();打印线条图形的方法:打印线条图形的方法:ev.Graphics.DrawLine(画笔, 起始位置, 终止位置);画笔的定义:画笔的定义:Pen p = new Pen(画笔的颜色, 画笔的宽度); 打印机打印事件的代码改为以下代码: Single linesPerPage = 0, startX = 0, startY = 0, Y;/startX = 0, startY = 0,Y文字输出的打印点坐标 int count = 0, startPX = 0, startPY =

45、 0, endPX = 0, endPY = 0;/count记录行数,其他的记录表格线条坐标位置 startX = ev.MarginBounds.Left + 120;/ev.MarginBounds .Left左页边距 startY = ev .MarginBounds .Top+30;/上页边距 string line = null; linesPerPage = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics);/每一页的打印行数,为页的高度除以打印字体的高度 /打印第一行 ; line =Space (6)+ 班级成

46、绩统计; printFont = new Font(Arial, 30);/第一行字的字体、字号 Y = startY + count * printFont.GetHeight(ev.Graphics); ; ev.Graphics.DrawString(line, printFont, Brushes.Blue, startX, Y, new StringFormat(); /打印第二行,打印课程名,打印日期 line = 课程名: + couresName + Space(50) + System.DateTime.Now.ToString(); count = count + 1; p

47、rintFont = new Font(Arial, 10);/后面要打印字的字体,字号 Y = startY + count * printFont.GetHeight(ev.Graphics)+40; ev.Graphics.DrawString(line, printFont, Brushes.Red, startX, Y, new StringFormat(); /计算画第一条表格线的起始坐标和终止坐标位置 startPX = (int)startX; startPY = (int)Y + (count + 1) * 16 - 8;/10号字的高度是16,减8是为了画的线在这一行的中间

48、 endPX = startPX + 440; endPY = startPY; /第四行 count = count + 2; Y = startY + count * printFont.GetHeight(ev.Graphics)+40; line = 班级名称; ev.Graphics.DrawString(line, printFont, Brushes.Green, startX + 20, Y, new StringFormat(); line = 人数; ev.Graphics.DrawString(line, printFont, Brushes.Green, startX

49、+ 130, Y, new StringFormat(); line = 总分; ev.Graphics.DrawString(line, printFont, Brushes.Green, startX + 240, Y, new StringFormat(); line = 备注; ev.Graphics.DrawString(line, printFont, Brushes.Green, startX + 350, Y, new StringFormat(); /第六行后,可能有多行,n是查询得到数据的行数 for (int i = 0; i n; i+) count = count +

50、 2; Y = startY + count * printFont.GetHeight(ev.Graphics) + 40; line = className i; ev.Graphics.DrawString(line, printFont, Brushes.Green, startX + 20, Y, new StringFormat(); line = RenShu i; ev.Graphics.DrawString(line, printFont, Brushes.Green, startX + 130, Y, new StringFormat(); line = Sumfi; ev

51、.Graphics.DrawString(line, printFont, Brushes.Green, startX + 240, Y, new StringFormat(); /表格的汇总行 count = count + 2; Y = startY + count * printFont.GetHeight(ev.Graphics) + 40; line = 汇总; ev.Graphics.DrawString(line, printFont, Brushes.Green, startX + 20, Y, new StringFormat(); line = RenshuTotal.To

52、String(); ev.Graphics.DrawString(line, printFont, Brushes.Green, startX + 130,Y, new StringFormat(); line = SumTotal.ToString(); ev.Graphics.DrawString(line, printFont, Brushes.Green, startX + 240, Y, new StringFormat(); /计算画最后一条表格线条的起始位置和终止位置 /画横线,画线条数应该是数据行n+标题行1+汇总行1+1 for (int i = 0; i n + 3; i+

53、) Pen p = new Pen(Color.Red, 1);/定义画笔及画笔的颜色和宽度 Point startP = new Point(startPX, startPY); Point endP = new Point(endPX, endPY); ev.Graphics.DrawLine(p, startP, endP); startPY = startPY + 2 * 16;/下一条线的y坐标位置,10号字符的高度是16 endPY = startPY; /画纵线 endPY = endPY - 32; endPX = startPX; startPX = endPX; start

54、PY = endPY - (n + 2) * 2 * 16; for (int j = 0; j 5; j+) Pen p = new Pen(Color.Red, 1);/定义画笔及画笔的颜色和宽度 Point startP = new Point(startPX, startPY); Point endP = new Point(endPX, endPY); ev.Graphics.DrawLine(p, startP, endP); startPX = startPX + 110;/每一个列宽是110 endPX = startPX; line = null; /如果有更多的行,打印另一

55、些页 if (line != null) ev.HasMorePages = true; else ev.HasMorePages = false;优点:表格打印优点:表格打印线条无缝对接,线条无缝对接,没有制表符哪样没有制表符哪样的接口。的接口。在表格中输出图片并分页打印。添加命名空间: using System.Drawing.Printing;添加类的成员变量: DataSet ds1 = new DataSet(); int n = 0;/存储数据集的记录数 private System .Drawing . Font printFont = new System.Drawing.Fo

56、nt(Arial, 10);/设置打印字体 string stuNo ;/学号 string stuName ;/学生名称 string Sex ;/性别 string Birthday ;/出生日期 string Tel;/电话 Bitmap img ;/图片 int pageCount = 0;/用于控制当前打印的页数 int k = 0;/用于控制当前打印的记录的记录号 int m = 0;/用于控制每页打印的最后一条记录的记录号打印事件代码:private void pd_PrintPage(object sender, PrintPageEventArgs ev)/定义打印事件 pa

57、geCount+; if (pageCount = System.Math.Ceiling(n / 7.0)/每页打印7条记录的信息,n是记录的总条数 ev.HasMorePages = true;/可以实现分页打印 m = pageCount * 7 - 1;/每一页最后一条记录的记录号的最大可能值 k = pageCount * 7 - 7;/每一条的第一条记录的记录号 /以下代码是用制表符打印表格 Single yPos = 0; int count = 0; Single leftMargin = 120;/左页边距 Single topMargin = ev.MarginBounds

58、.Top - 30;/上页边距 string line = null; /打印第一行 line = 学生花名册名片; printFont = new System.Drawing.Font (Arial, 30); yPos = topMargin + count * printFont.GetHeight(ev.Graphics); ev.Graphics.DrawString(line, printFont, Brushes.Blue, leftMargin+50, yPos, new StringFormat(); /打印第二行,打印日期 line = 打印日期: + System.Da

59、teTime.Now.ToString(); printFont = new System.Drawing .Font (Arial, 10); count = count + 1; yPos = topMargin + count * printFont.GetHeight(ev.Graphics) + 40; ev.Graphics.DrawString(line, printFont, Brushes.Red, leftMargin+100, yPos, new StringFormat(); /打印第三行,主要是制表符 for (; k = n)/当前要打印的记录的记录号超过或者等于数

60、据集的记录数时,不再打印多页,并退出循环 ev.HasMorePages = false; line = null; img = null; pageCount = 0; break; count = count + 1; line = ; yPos = topMargin + count * printFont.GetHeight(ev.Graphics) + 40; ev.Graphics.DrawString(line, printFont, Brushes.Green, leftMargin, yPos, new StringFormat(); line = ; ev.Graphics

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论