我試圖用下面的代碼打印位圖,但它不起作用。我不知道爲什麼....C#打印圖像不起作用
private void btnImprimir_Click(object sender, EventArgs e)
{
PrintDocument pd = new PrintDocument();
pd.PrintPage += PrintPage;
pd.Print();
}
private void PrintPage(object o, PrintPageEventArgs e)
{
button1.Visible = false;
button2.Visible = false;
button3.Visible = false;
button4.Visible = false;
Bitmap bitmap = new Bitmap(this.Width, this.Height);
this.DrawToBitmap(bitmap, this.ClientRectangle);
Point loc = new Point(this.Width, this.Height);
e.Graphics.DrawImage(bitmap, loc);
button1.Visible = true;
button2.Visible = true;
button3.Visible = true;
button4.Visible = true;
}
1.你的意思是什麼不起作用? (它不打印,它是否打印空白頁?) 2.您是否嘗試將位圖保存到磁盤並查看它? – Peter
我已經編輯了我的問題並刪除了評論 – Ladessa
好吧,我改變了... – Ladessa