我想打印一份表格。我有這個代碼,但我不能選擇要打印的打印機,而是使用默認打印機打印。我該如何解決這個問題?如何在C#中打印表單?
void PrintImage(object o, PrintPageEventArgs e)
{
int x = SystemInformation.WorkingArea.X;
int y = SystemInformation.WorkingArea.Y;
int width = this.Width;
int height = this.Height;
Rectangle bounds = new Rectangle(x, y, width, height);
Bitmap img = new Bitmap(width, height);
this.DrawToBitmap(img, bounds);
Point p = new Point(100, 100);
e.Graphics.DrawImage(img, p);
}
private void button1_Click(object sender, EventArgs e)
{
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(PrintImage);
pd.Print();
}
這看起來像winforms,是正確的?我還建議列出至少一個您嘗試過的解決方案,以及爲什麼/如何失敗。 – clarkitect