我想打印一份表格。我有这个代码,但我不能选择要打印的打印机,而是使用默认打印机打印。我该如何解决这个问题?如何在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