求助 C#打印picturebox
我导入数据后,picturebox内自动生成了曲线图,我另加了一个打印按钮,希望按下打印按钮后,能够打印picturebox内的曲线图,我是一个初学者,希望高手帮帮忙,先谢谢了!
回复 3楼 zhp223
我不明白打印事件是怎么发生的如果我是:
private void button2_Click(object sender, EventArgs e)
{
PrintDialog MyPrintDg = new PrintDialog();
MyPrintDg.Document = printDocument2;
printDocument2.PrintPage += new PrintPageEventHandler(this.printDocument2_PrintPage);
if (MyPrintDg.ShowDialog() == DialogResult.OK)
{
try
{
printDocument2.Print();
}
catch
{ //停止打印
printDocument2.PrintController.OnEndPrint(printDocument2, new System.Drawing.Printing.PrintEventArgs());
}
}
}
private void printDocument2_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawImage(pictureBoxBoXing.Image, 0, 0);
e.HasMorePages = true;//允许多页打印
}
这是哪儿错了,根本打印不出东西来,特别是到e.Graphics.DrawImage(pictureBoxBoXing.Image, 0, 0);
这一句就不执行了!希望你指点一下,谢谢了!