【发布时间】:2014-07-06 18:19:38
【问题描述】:
我想打印一个表格。我有这个代码,但我无法选择要打印的打印机,它使用默认打印机打印。我该如何解决这个问题?
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,对吗?我还建议列出您尝试过的至少一种解决方案以及失败的原因/方式。