我已經使用下面的代碼來打印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