我正在尝试在 MdiChild 中打印图片框的内容。调试代码看起来永远不会触发 PrintPage 事件。我主要将此代码用于该项目:printing content of a picturebox
怎么了 ?
这是我的代码:
private void stampaToolStripMenuItem_Click(object sender, EventArgs e)
{
Form2 activeChild = this.ActiveMdiChild as Form2;
PictureBox theBox = (PictureBox)activeChild.pictureBox1;
dastampare = theBox.Image as Bitmap;
printDocument1.OriginAtMargins = true;
printDocument1.DocumentName = "Prova";
printDialog1.Document = printDocument1;
printDialog1.ShowDialog();
if (printDialog1.ShowDialog() == DialogResult.OK)
{
printDocument1.Print();
}
}
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawImage(dastampare, 0, 0);
}