日期:2014-05-17 浏览次数:20985 次
private void button打印设置_Click(object sender, EventArgs e) { pageSetupDialog1.Document = printDocument1; pageSetupDialog1.ShowDialog(); } private void button打印预览_Click(object sender, EventArgs e) { printPreviewDialog1.Document = printDocument1; printPreviewDialog1.ShowDialog(); } private void button打印_Click(object sender, EventArgs e) { printDocument1.Print(); } private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { e.Graphics.DrawRectangle(Pens.Black, e.PageSettings.Margins.Left, e.PageSettings.Margins.Top, e.MarginBounds.Width, e.MarginBounds.Height); e.Graphics.DrawString("Hello,world!", new Font("宋体", 20), Brushes.Black, e.PageSettings.Margins.Left, e.PageSettings.Margins.Top); }
------解决方案--------------------
哦,写错了:应该是PageSetupDialog控件,PrintDocument控件、PrintPreviewDialog控件各一个
中文是我起得按钮的名字为"button打印预览",你双击它就会自动添加相应事件方法名,英文也可以,这个米有关系。