关于打印问题求助 在窗体中插入了label,textbox,dateTimePicker等控件如何把他们输出到打印机上打印?我是新手希望大家赐教,我目前只是知道调用printDocument控件然后print事件,但是这样出来好像是空白?有待高人解决,在线等! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你是要打印string类型的值, 还是要把控件截图打印?如果是截图打印, Control上有个DrawToBitmap方法。 这个需求不是简单调一下printDocument解决的,需要自己处理Print的逻辑,在哪儿画,什么字体,都要自己写 类似于报表那样, 你需要控制打印机打印你所需输出的数据.具体参考: http://topic.csdn.net/u/20090811/16/429f6dc6-7517-48b9-9e6a-8aaf0c6e2d52.html 之7, 8楼. 问题解决了,谢谢大家 private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { String biaoti = "通讯产品保修卡"; String leibie = "产品类别:"; String leibiet = comboBox1.Text; String model = "产品型号:"; String modelt = textBox1.Text; String sn = "序列号(IMEI):"; String snt = textBox2.Text; String nowtime ="销售时间:"; String nowtimet = dateTimePicker2.Text; String otime ="质保时间至:"; String otimet = dateTimePicker1.Text; String sm = "敬告:凭此保修卡进行质保,丢失、涂"; String sm2 = "改或污垢不予保修,请妥善保存!"; Font drawFont = new Font("微软雅黑", 12); Font drawFont1 = new Font("微软雅黑", 9); Font drawFont2 = new Font("微软雅黑", 8); SolidBrush drawBrush = new SolidBrush(Color.Black); float x = 20.0F; float y = 20.0F; StringFormat drawFormat = new StringFormat(); drawFormat.FormatFlags = StringFormatFlags.NoWrap; e.Graphics.DrawString(biaoti, drawFont, drawBrush, x, y, drawFormat); e.Graphics.DrawString(leibie, drawFont1, drawBrush, x=0.0f, y=55.0f, drawFormat); e.Graphics.DrawString(leibiet, drawFont1, drawBrush, x = 80.0f, y = 55.0f, drawFormat); e.Graphics.DrawString(model, drawFont1, drawBrush, x = 0.0f, y = 75.0f, drawFormat); e.Graphics.DrawString(modelt, drawFont1, drawBrush, x = 80.0f, y = 75.0f, drawFormat); e.Graphics.DrawString(sn, drawFont2, drawBrush, x = 0.0f, y = 95.0f, drawFormat); e.Graphics.DrawString(snt, drawFont2, drawBrush, x = 82.0f, y = 95.0f, drawFormat); e.Graphics.DrawString(nowtime, drawFont1, drawBrush, x = 0.0f, y = 115.0f, drawFormat); e.Graphics.DrawString(nowtimet, drawFont1, drawBrush, x = 60.0f, y = 115.0f, drawFormat); e.Graphics.DrawString(otime, drawFont1, drawBrush, x = 0.0f, y = 135.0f, drawFormat); e.Graphics.DrawString(otimet, drawFont1, drawBrush, x = 70.0f, y = 135.0f, drawFormat); e.Graphics.DrawString(sm, drawFont2, drawBrush, x = 0.0f, y = 195.0f, drawFormat); e.Graphics.DrawString(sm2, drawFont2, drawBrush, x = 0.0f, y = 210.0f, drawFormat); e.Graphics.DrawImage(pictureBox1.Image,50,153, 80,23); //打印保修凭证章 e.HasMorePages = false; } 字符串替换问题 (在线等) 请教个ClickOnce打包的问题 下载了个c#的qq仿真程序,调试出现问题 使用C#编写的基于Web具有符号运算功能的数学公式编辑器 C#实现window上传? C#问题 急... 求助,求助!!!关于TemplateField 求大神帮助!!!C# ,瀑布流式网页爬虫。 VS.Net创建的部署项目,如何在菜单组添加一个“添加/删除”菜单? 写一个函数GetField(DataSet ds),在GetField中怎么样获取ds中的所有字段名? indexof()找不到的字符。大家来看看 菜鸟提问,this 的作用
如果是截图打印, Control上有个DrawToBitmap方法。
具体参考: http://topic.csdn.net/u/20090811/16/429f6dc6-7517-48b9-9e6a-8aaf0c6e2d52.html 之7, 8楼.
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
String biaoti = "通讯产品保修卡";
String leibie = "产品类别:";
String leibiet = comboBox1.Text;
String model = "产品型号:";
String modelt = textBox1.Text;
String sn = "序列号(IMEI):";
String snt = textBox2.Text;
String nowtime ="销售时间:";
String nowtimet = dateTimePicker2.Text;
String otime ="质保时间至:";
String otimet = dateTimePicker1.Text;
String sm = "敬告:凭此保修卡进行质保,丢失、涂";
String sm2 = "改或污垢不予保修,请妥善保存!";
Font drawFont = new Font("微软雅黑", 12);
Font drawFont1 = new Font("微软雅黑", 9);
Font drawFont2 = new Font("微软雅黑", 8);
SolidBrush drawBrush = new SolidBrush(Color.Black);
float x = 20.0F;
float y = 20.0F;
StringFormat drawFormat = new StringFormat();
drawFormat.FormatFlags = StringFormatFlags.NoWrap;
e.Graphics.DrawString(biaoti, drawFont, drawBrush, x, y, drawFormat);
e.Graphics.DrawString(leibie, drawFont1, drawBrush, x=0.0f, y=55.0f, drawFormat);
e.Graphics.DrawString(leibiet, drawFont1, drawBrush, x = 80.0f, y = 55.0f, drawFormat);
e.Graphics.DrawString(model, drawFont1, drawBrush, x = 0.0f, y = 75.0f, drawFormat);
e.Graphics.DrawString(modelt, drawFont1, drawBrush, x = 80.0f, y = 75.0f, drawFormat);
e.Graphics.DrawString(sn, drawFont2, drawBrush, x = 0.0f, y = 95.0f, drawFormat);
e.Graphics.DrawString(snt, drawFont2, drawBrush, x = 82.0f, y = 95.0f, drawFormat);
e.Graphics.DrawString(nowtime, drawFont1, drawBrush, x = 0.0f, y = 115.0f, drawFormat);
e.Graphics.DrawString(nowtimet, drawFont1, drawBrush, x = 60.0f, y = 115.0f, drawFormat);
e.Graphics.DrawString(otime, drawFont1, drawBrush, x = 0.0f, y = 135.0f, drawFormat);
e.Graphics.DrawString(otimet, drawFont1, drawBrush, x = 70.0f, y = 135.0f, drawFormat);
e.Graphics.DrawString(sm, drawFont2, drawBrush, x = 0.0f, y = 195.0f, drawFormat);
e.Graphics.DrawString(sm2, drawFont2, drawBrush, x = 0.0f, y = 210.0f, drawFormat);
e.Graphics.DrawImage(pictureBox1.Image,50,153, 80,23); //打印保修凭证章
e.HasMorePages = false;
}