我想打印整个窗体,这个窗体不显示,lable和条码控件能打出来 但是PictureBox和LineShape(VB里的画线)打出来空白的,小弟新手,请高手帮帮忙
我用的打印方法:private void pd_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
Bitmap bit = new Bitmap(frm.Width, frm.Height);
frm.DrawToBitmap(bit, new Rectangle(0, 0, frm.Width, frm.Height));
bit.Save("D://AAA.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
e.Graphics.DrawImage(bit, 0, 0, bit.Width, bit.Height);
bit.Dispose();
}
我用的打印方法:private void pd_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
Bitmap bit = new Bitmap(frm.Width, frm.Height);
frm.DrawToBitmap(bit, new Rectangle(0, 0, frm.Width, frm.Height));
bit.Save("D://AAA.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
e.Graphics.DrawImage(bit, 0, 0, bit.Width, bit.Height);
bit.Dispose();
}
{
foreach (Control c in frm.Controls)
{
if (c is UserLable)
{
e.Graphics.DrawString(c.Text, c.Font,
new SolidBrush(c.ForeColor), c.Location);
}
else if (c is PictureBox)
{
PictureBox b = (PictureBox)c;
e.Graphics.DrawImage(b.Image, c.Location.X,
c.Location.Y, c.Width, c.Height);
}
else if (c is BarcodeControl)
{
BarcodeControl b = (BarcodeControl)c;
Bitmap bit = new Bitmap(b.Width, b.Height);
b.DrawToBitmap(bit, new Rectangle(0, 0, b.Width, b.Height));
e.Graphics.DrawImage(bit, b.Location.X,b.Location.Y, bit.Width, bit.Height);
}
else if (c is ShapeContainer)
{
ShapeContainer b = (ShapeContainer)c;
foreach (Shape sh in b.Shapes)
{
if (sh is LineShape)
{
LineShape lin = (LineShape)sh;
Pen mypen = new Pen(lin.BorderColor, lin.BorderWidth);
mypen.DashStyle = lin.BorderStyle;
e.Graphics.DrawLine(mypen, lin.StartPoint, lin.EndPoint);
}
}
}
} }