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));
}

解决方案 »

  1.   

    我有一个打印控件你要不要啊,可以在vb,vb.net,c#中使用,很强大!
      

  2.   

    <OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0></OBJECT>
    <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)>