社区
C#
帖子详情
谁知道System.Drawing.Printing.PrintEventArgs怎么用?
nobounded
2003-11-07 10:08:06
谁知道System.Drawing.Printing.PrintEventArgs怎么用?给些具体的例子,能不能对打印进行监视?(就是能不能得到一些打印的事件).
...全文
287
7
打赏
收藏
谁知道System.Drawing.Printing.PrintEventArgs怎么用?
谁知道System.Drawing.Printing.PrintEventArgs怎么用?给些具体的例子,能不能对打印进行监视?(就是能不能得到一些打印的事件).
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
7 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
brightheroes
2003-12-08
打赏
举报
回复
try
{
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler( PrintInOut );
pd.Print();
}
catch
{
this.sp_description.Text = "打印失败!请检查打印机是否可用...........";
return;
}
brightheroes
2003-12-08
打赏
举报
回复
给你一段代码,你看看
/// <summary>
/// 打印水单
/// </summary>
/// <param name="sender"></param>
/// <param name="ev"></param>
private void PrintInOut(object sender, PrintPageEventArgs ev)
{
Font printFont;
String str, temp;
float yPos = 0;
int count = 0;
float leftMargin = 0; //ev.MarginBounds.Left;
float topMargin = 0; //ev.MarginBounds.Top;
printFont = new Font("黑体", 12);
str = "欢 迎 光 临";
yPos = topMargin + ((count++) * printFont.GetHeight(ev.Graphics));
ev.Graphics.DrawString (str, printFont, Brushes.Black, leftMargin, yPos, new StringFormat());
count++; //加一空行
// printFont = new Font("黑体", 12);
// str = uncString.FillLeftSpace( this.labelShopName.Text, 20 - this.labelShopName.Text.Length );
// yPos = topMargin + ((count++) * printFont.GetHeight(ev.Graphics));
// ev.Graphics.DrawString (str, printFont, Brushes.Black, leftMargin, yPos, new StringFormat());
printFont = new Font("新宋体", 10);
str = "========================================";
yPos = topMargin + ((count++) * printFont.GetHeight(ev.Graphics)) + 5;
ev.Graphics.DrawString (str, printFont, Brushes.Black, leftMargin, yPos, new StringFormat());
//打印流水号
str = "流水号:"+this.lb_inout_code.Text;
yPos = topMargin + ((count++) * printFont.GetHeight(ev.Graphics));
ev.Graphics.DrawString ( str, printFont, Brushes.Black, leftMargin, yPos, new StringFormat());
str = "----------------------------------------";
yPos = topMargin + ((count++) * printFont.GetHeight(ev.Graphics));
ev.Graphics.DrawString ( str, printFont, Brushes.Black, leftMargin, yPos, new StringFormat());
str = " 品名 单价 数量 折扣 金额";
yPos = topMargin + ((count++) * printFont.GetHeight(ev.Graphics));
ev.Graphics.DrawString ( str, printFont, Brushes.Black, leftMargin, yPos, new StringFormat());
str = "----------------------------------------";
yPos = topMargin + ((count++) * printFont.GetHeight(ev.Graphics));
ev.Graphics.DrawString ( str, printFont, Brushes.Black, leftMargin, yPos, new StringFormat());
foreach(DataRow dr in this.dtInout.Rows)
{
str = dr["item_name"].ToString(); //打印品名
yPos = topMargin + ((count++) * printFont.GetHeight(ev.Graphics));
ev.Graphics.DrawString ( str , printFont, Brushes.Black, leftMargin, yPos, new StringFormat());
if(dr["item_discount"].ToString() == "100")
{
temp = " ";
}
else
{
temp = uncString.FillLeftSpace(dr["item_discount"].ToString(),5);
}
//打印单价、数量、折扣、金额
str = " " +
uncString.FillLeftSpace( dr["item_price"].ToString(), 7 ) +
uncString.FillLeftSpace( dr["item_qty"].ToString(), 7 ) +
temp +
uncString.FillLeftSpace( dr["item_amount"].ToString(), 10 );
yPos = topMargin + ((count++) * printFont.GetHeight(ev.Graphics));
ev.Graphics.DrawString ( str , printFont, Brushes.Black, leftMargin, yPos, new StringFormat());
}
str = "----------------------------------------";
yPos = topMargin + ((count++) * printFont.GetHeight(ev.Graphics));
ev.Graphics.DrawString ( str, printFont, Brushes.Black, leftMargin, yPos, new StringFormat());
str = " 合计: " +
uncString.FillLeftSpace( this.lb_act_amount.Text.ToString(), 11 );
yPos = topMargin + ((count++) * printFont.GetHeight(ev.Graphics));
ev.Graphics.DrawString ( str , printFont, Brushes.Black, leftMargin, yPos, new StringFormat());
str = " 收银: " +
uncString.FillLeftSpace(this.tb_Money.Text.ToString(), 11 );
yPos = topMargin + ((count++) * printFont.GetHeight(ev.Graphics));
ev.Graphics.DrawString ( str , printFont, Brushes.Black, leftMargin, yPos, new StringFormat());
if ( this.lb_change.Text != "0.00" )
{
str = " 找零: " +
uncString.FillLeftSpace( this.lb_change.Text, 11 );
yPos = topMargin + ((count++) * printFont.GetHeight(ev.Graphics));
ev.Graphics.DrawString ( str , printFont, Brushes.Black, leftMargin, yPos, new StringFormat());
}
count++; //加一空行
str = DateTime.Now.ToString( "yyyy.MM.dd HH:mm:ss" );
yPos = topMargin + ((count++) * printFont.GetHeight(ev.Graphics));
ev.Graphics.DrawString ( str, printFont, Brushes.Black, leftMargin, yPos, new StringFormat());
//滚动6行
count += 5;
str = " ";
yPos = topMargin + ((count++) * printFont.GetHeight(ev.Graphics));
ev.Graphics.DrawString ( str, printFont, Brushes.Black, leftMargin, yPos, new StringFormat());
}
nobounded
2003-12-05
打赏
举报
回复
打印监视器类?什么东西,哪有?
ansonzts
2003-11-08
打赏
举报
回复
刚做完打印,感觉System.Drawing.Printing.PrintEventArgs很有用,通过该事件类,可以获得打印的区域,打印的graphics对象。对打印进行监视觉得不行,可以用打印监视器类来实现。
513
2003-11-08
打赏
举报
回复
PrintPage事件
这里有个例子
ms-help://MS.VSCC/MS.MSDNVS.2052/cpref/html/frlrfsystemdrawingprintingprintdocumentclasstopic.htm
chenshi999
2003-11-08
打赏
举报
回复
对打印进行好好的控制,需要自行继承编辑PrintController子类。
wangke1220
2003-11-07
打赏
举报
回复
up
打印系统开发(58)——打印系统开发笔记
一、打印控件: PrintDocument:要打印的对象。 PageSetupDialog:打印设置对话框。 PrintPreviewControl:打印预览控件。 PrintPreviewDialog:打印预览对话框。 PrintDialog:打印对话框。 二、相关软件 我们的产品是基于Adobe来开发的,我们首先得
知道
这个功能具体是如何实现的,才好调查用我们的产...
打印控件
使用打印控件首先需要先创建printdocument对象:使用printpage触发事件 private void printDocument1_PrintPage(object sender,
System
.
Drawing
.
Printing
.PrintPageEventArgs e) { Font f=new
System
.
Drawing
.Fon...
dev_XtraReports在打印预览事件中,自动生成序号
dev_XtraReports在打印预览事件中,自动生成序号 如下图 通过在报表此控件的BeforePrint事件中写如下代码实现 int IntXH = 0; private void xrTableCell1_BeforePrint(object sender,
System
.
Drawing
.
Printing
.
PrintEventArgs
e)
DevExpress 报表 格式化
private void boolTableCell_BeforePrint(object sender,
System
.
Drawing
.
Printing
.
PrintEventArgs
e) { boolTableCell.Text = Convert.ToBoolean(boolTableCell.Text.ToLower()) ? "是" : "否"
c# 小票机打印二维条码_C#小票打印机
使用的佳博GP-5890XIIIusing
System
;using
System
.Collections.Generic;using
System
.ComponentModel;using
System
.Data;using
System
.
Drawing
;using
System
.
Drawing
.
Drawing
2D;using
System
.
Drawing
.
Printing
;using Syst...
C#
110,566
社区成员
642,567
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章