我已经使用下面的代码来打印Windows窗体的面板。标签不显示在打印
private void button1_Click(object sender, EventArgs e)
{
System.Drawing.Printing.PrintDocument doc = new System.Drawing.Printing.PrintDocument();
doc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(Doc_PrintPage);
doc.Print();
}
private void Doc_PrintPage(object sender, PrintPageEventArgs e)
{
Panel grd = new Panel();
Bitmap bmp = new Bitmap(panel2.Width, panel2.Height, panel2.CreateGraphics());
panel2.DrawToBitmap(bmp, new Rectangle(0, 0, panel2.Width, panel2.Height));
RectangleF bounds = e.PageSettings.PrintableArea;
float factor = ((float)bmp.Height/(float)bmp.Width);
e.Graphics.DrawImage(bmp, bounds.Left, bounds.Top, bounds.Width, factor * bounds.Width);
bmp.Save("test12.jpg");
}
现在从上面的代码,当我点击按钮打印功能将被打电话,但它将排除其中的标签。我附上图片供您参考。第一个图像是我的UI设计。 ,当我使用打印功能时,它将删除标签值,如您在其他图像中看到的那样。 我已经使用了rectagleshap控件,它们都是粉红色的,我在上面显示标签。我认为标签可能会发回,但是当我使用前端时,它也不会出现。
MCVE中的M表示*最小*。 –
@HansPassant不明白你的意思。 – Developer