日期:2014-05-18 浏览次数:21453 次
PrintDialog printDialog = new PrintDialog(); printDialog.Document = this.printDocument1; printDocument1.DefaultPageSettings.PaperSize = new PaperSize("Default", 315, 394); if (printDialog.ShowDialog() == DialogResult.OK) { try { printDocument1.Print(); } catch (Exception excep) { MessageBox.Show(excep.Message, "打印出错", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button1_Click(object sender, EventArgs e) { if (printDialog1.ShowDialog() == DialogResult.OK) { try { printDocument1.PrintPage +=new System.Drawing.Printing.PrintPageEventHandler(printDocument1_PrintPage); printDocument1.DefaultPageSettings.PaperSize = new PaperSize("Default", 200, 150); printDocument1.Print(); } finally { } } } private void printDocument1_PrintPage(object sender, PrintPageEventArgs ev) { ev.Graphics.DrawString("haha", new Font("宋体", 10), Brushes.Black, new PointF(10, 10)); }
------解决方案--------------------
LZ加我Q453367672
我有demo,源码献上