环境:VS2005,C#,Winform窗口上有四个标签,分别对应四个文本框:
姓名:张飞
年龄:32
职位:大将
打印份数:3还有一个Button(Btn_Print),现在想一按打印按钮就把张飞的信息直接打印到条码打印机(打印多少张根据txtnumber.Text的值来定),条码打印机的标签尺寸为(5cm X 5cm),printDocument1的PrintPage事件为OnPrintPage,本人不太熟悉C#的打印,我的代码如下:
private void Btn_Print_Click(object sender, EventArgs e)
{ sname = txtname.Text;
sage = txtage.Text;
spos = txtpos.Text; try
{
printDocument1.Print();
}
catch (InvalidPrinterException ex)
{
MessageBox.Show(ex.Message, "Simple Editor", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
} private void OnPrintPage(object sender, PrintPageEventArgs e)
{
for (int i = 1; i <= Convert.ToInt32(txtnumber.Text); i++)
{
e.Graphics.DrawString(" ", new Font("Arial", 14, FontStyle.Bold), Brushes.Black, 75, 0);
e.Graphics.DrawString(sname, new Font("Arial", 14, FontStyle.Bold), Brushes.Black, 75, 30);
e.Graphics.DrawString(" ", new Font("Arial", 14, FontStyle.Bold), Brushes.Black, 75, 60);
e.Graphics.DrawString(sage, new Font("Arial", 14, FontStyle.Bold), Brushes.Black, 75, 90);
e.Graphics.DrawString(spos, new Font("Arial", 12, FontStyle.Bold), Brushes.Black, 75, 120); }
}问题:
1.打印的时候并不是从第一张标签纸开始的,张飞的名字出现在第三张标签纸的末尾
2.最终只打印出一次信息,并没有打印出三次(txtnumber.Text的值设定)怎么解决以上问题啊?五行打印内容在一张标签纸上完全可以打得下的,怎么会这样?
另外打第二次的时候,怎么让信息出现在另外一张标签纸上,而不是接在第一张标签上继续打?
在线等!!!!!!!!!!!
姓名:张飞
年龄:32
职位:大将
打印份数:3还有一个Button(Btn_Print),现在想一按打印按钮就把张飞的信息直接打印到条码打印机(打印多少张根据txtnumber.Text的值来定),条码打印机的标签尺寸为(5cm X 5cm),printDocument1的PrintPage事件为OnPrintPage,本人不太熟悉C#的打印,我的代码如下:
private void Btn_Print_Click(object sender, EventArgs e)
{ sname = txtname.Text;
sage = txtage.Text;
spos = txtpos.Text; try
{
printDocument1.Print();
}
catch (InvalidPrinterException ex)
{
MessageBox.Show(ex.Message, "Simple Editor", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
} private void OnPrintPage(object sender, PrintPageEventArgs e)
{
for (int i = 1; i <= Convert.ToInt32(txtnumber.Text); i++)
{
e.Graphics.DrawString(" ", new Font("Arial", 14, FontStyle.Bold), Brushes.Black, 75, 0);
e.Graphics.DrawString(sname, new Font("Arial", 14, FontStyle.Bold), Brushes.Black, 75, 30);
e.Graphics.DrawString(" ", new Font("Arial", 14, FontStyle.Bold), Brushes.Black, 75, 60);
e.Graphics.DrawString(sage, new Font("Arial", 14, FontStyle.Bold), Brushes.Black, 75, 90);
e.Graphics.DrawString(spos, new Font("Arial", 12, FontStyle.Bold), Brushes.Black, 75, 120); }
}问题:
1.打印的时候并不是从第一张标签纸开始的,张飞的名字出现在第三张标签纸的末尾
2.最终只打印出一次信息,并没有打印出三次(txtnumber.Text的值设定)怎么解决以上问题啊?五行打印内容在一张标签纸上完全可以打得下的,怎么会这样?
另外打第二次的时候,怎么让信息出现在另外一张标签纸上,而不是接在第一张标签上继续打?
在线等!!!!!!!!!!!
解决方案 »
- 多线程 绑定的方法如何传参数 急问
- 请问怎样用C#控制读取智能卡上的数据 如SD卡 手机卡 等`
- 菜单项问题
- 问两个关于控件的问题
- 如何读取一个指定目录的目录结构和相关文件路径???
- 再次求!!!一个跟时间字段有关的SQL语句,帮忙看看!!!!!
- 大哥们,救救我!!button1_Click后button2_Click报错,找不到@"..\..\file.mdb",直接button2_Click,就可以,为什么??
- .NET Thread类创建的线程是在CPU一个核上面还是多个核上面?
- NPOI 【.xlsx】文件生成,报损坏错误
- 关于 OwnerDraw 菜单。
- sql数据导出到EXCEL的字段格式问题
- C#中怎样提取ListBox里的所有项
你可以看一下我写的关于条码的!你要打印的时候也要先画好,这样在打印就好了!
for (int i = 1; i <= Convert.ToInt32(txtnumber.Text); i++)
{
e.Graphics.DrawString(" ", new Font("Arial", 14, FontStyle.Bold), Brushes.Black, 75, 0); //加这句是什么意思,不打印任何东西,这可以去掉这条语句
e.Graphics.DrawString(sname, new Font("Arial", 14, FontStyle.Bold), Brushes.Black, 75, 30);
e.Graphics.DrawString(" ", new Font("Arial", 14, FontStyle.Bold), Brushes.Black, 75, 60);
e.Graphics.DrawString(sage, new Font("Arial", 14, FontStyle.Bold), Brushes.Black, 75, 90);
e.Graphics.DrawString(spos, new Font("Arial", 12, FontStyle.Bold), Brushes.Black, 75, 120); } 张飞的名字出现在第三张标签纸的末尾 :这个可能是你坐标设置的问题吧!
ASPX如下:
<div class="Noprint">
<a href="#" onclick="document.all.WebBrowser.ExecWB(7,1);" >打印</a>
<OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0></OBJECT>
</div>
css如下:
.Noprint
{
display:none;
} .PageNext
{
page-break-after: always;
}.PrintWidth
{
width:100%;
}