private void button1_Click(object sender, System.EventArgs e)
{
this.printDialog1.Document=printDocument1;
if(printDialog1.ShowDialog(this)==DialogResult.OK)
{
printDocument1.PrinterSettings=printDialog1.PrinterSettings;
}
this.printPreviewDialog1.ShowDialog();
this.printDocument1.PrintPage +=new System.Drawing.Printing.PrintPageEventHandler(this.pd_printPage);
this.printDocument1.Print();
}
private void pd_printPage(object o,System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawString("asdfsdafasd",new Font("宋体",10),System.Drawing.Brushes.Blue,new Point(1,1));
}
{
this.printDialog1.Document=printDocument1;
if(printDialog1.ShowDialog(this)==DialogResult.OK)
{
printDocument1.PrinterSettings=printDialog1.PrinterSettings;
}
this.printPreviewDialog1.ShowDialog();
this.printDocument1.PrintPage +=new System.Drawing.Printing.PrintPageEventHandler(this.pd_printPage);
this.printDocument1.Print();
}
private void pd_printPage(object o,System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawString("asdfsdafasd",new Font("宋体",10),System.Drawing.Brushes.Blue,new Point(1,1));
}
解决方案 »
- C#如何按顺序动态添加Resources文件夹里的图片?
- GBK 中文编码问题
- 请求各位大侠救助,
- 将gif格式的图片放入imageList中,然后用picturebox调用,结果图片显示静态的,怎么解决?
- 怎么读取string 变量中的xml属性?
- 百分求繁简转换源代码
- textbox进行绑定后的疑问?
- 很棘手的问题?不知道该怎么办才好!
- 笛卡尔-心形图 源代码 分析
- 如何用c#开发dll
- 如何在Winform控制嵌入的浏览器对web构件的显示
- 如果是你,你会怎么做??~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~``
<input type=button value=打印 onclick=document.all.WebBrowser.ExecWB(6,1)>
<input type=button value=直接打印 onclick=document.all.WebBrowser.ExecWB(6,6)>
<input type=button value=页面设置 onclick=document.all.WebBrowser.ExecWB(8,1)><input type=button value=打印预览 onclick=document.all.WebBrowser.ExecWB(7,1)>