如何在C#中打印完整的Windows应用程序表格 [英] How to print complete windows application form in c#
本文介绍了如何在C#中打印完整的Windows应用程序表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
非常紧急...我正在开发数据库应用程序n我想打印完整的
Windows应用程序窗体.
its very urgent... i m working on database application n i want to print a complete
windows application form.
推荐答案
有两种方法可以做到这一点:
快速又肮脏: PrintForm [ PrintDocument [
There are two ways to do this:
Quick and dirty: The PrintForm[^] class
A bit slower to implement: the PrintDocument[^] class.
The former generally produces a nasty print as it does just what it says on the tin: prints a copy of the form.
The latter is more work to implement, but produces a much, much better result and is a lot more flexible.
I do not use the former; once you are familiar with the latter you will see why!
您好,
希望这对您有帮助.
Hello,
Hope this will helps you.
// Handler for print call
private void ButtonPrintClick(object sender, EventArgs e)
{
// Create document
PrintDocument _document = new PrintDocument();
// Add print handler
_document.PrintPage += new PrintPageEventHandler(Document_PrintPage);
// Create the dialog to display results
PrintPreviewDialog _dlg = new PrintPreviewDialog();
_dlg.ClientSize = new System.Drawing.Size(Width / 2, Height / 2);
_dlg.Location = new System.Drawing.Point(Left, Top);
_dlg.MinimumSize = new System.Drawing.Size(375, 250);
_dlg.UseAntiAlias = true;
// Setting up our document
_dlg.Document = _document;
// Show it
_dlg.ShowDialog(this);
// Dispose document
_document.Dispose();
}
// Print handler
private void Document_PrintPage(object sender, PrintPageEventArgs e)
{
// Create Bitmap according form size
Bitmap _bitmap = new Bitmap(Width, Height, System.Drawing.Imaging.PixelFormat.Format32bppRgb);
// Draw from into Bitmap DC
this.DrawToBitmap(_bitmap, this.DisplayRectangle);
// Draw Bitmap into Printer DC
e.Graphics.DrawImage(_bitmap,0,0);
// No longer deeded - dispose it
_bitmap.Dispose();
}
问候,
Maxim.
Regards,
Maxim.
请参阅编号.此链接中的2
http://social.msdn.microsoft.com /Forums/zh-CN/csharpgeneral/thread/eb80fbbe-6b89-4c3d-9ede-88a2b105c714/
或使用printform控件
http://www.dreamincode.net/forums/topic/81085-print-form/ [ ^ ]
祝您编码愉快!
:)
refer answer no. 2 in this link
http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/eb80fbbe-6b89-4c3d-9ede-88a2b105c714/
or use printform control
http://www.dreamincode.net/forums/topic/81085-print-form/[^]
Happy Coding!
:)
这篇关于如何在C#中打印完整的Windows应用程序表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文