有用的表格印刷

时间:2011-03-03 10:02:37

标签: vb.net winforms visual-studio-2010 windows

我正在搜索在WindowsForm应用程序中打印整个表单/多个Datagridviews和一些特定控件内容的最佳方法。

我知道互联网已经充满了坏的和好的例子。

很难将Good示例与Bad示例分开。

那你能告诉我什么?

你的方法是什么?网上的例子有用吗?

提前致谢

2 个答案:

答案 0 :(得分:0)

试试这段代码。这将打印当前表单的所有内容。

using (Bitmap bmp = new Bitmap(this.Width, this.Height))
{
    this.DrawToBitmap(bmp, this.ClientRectangle);
    using (PrintDocument p = new PrintDocument())
    {
        p.PrintPage += (o, pe) =>
            {
                pe.Graphics.DrawImage(bmp, this.ClientRectangle);
            };
        p.Print();
    }
}

抱歉,我没有测试过。

答案 1 :(得分:0)

您可以从要打印的表单创建快照,然后打印图像。

要创建快照,您可以查看here

相关问题