且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在.net中打印Windows窗体

更新时间:2023-12-06 12:58:40

如果要打印整个表单,则可以使用Visual Basic PowerPacks工具箱中的PrintForm控件.
相同 http://www.microsoft.com/download/zh-CN/details的链接.aspx?displaylang = en& id = 25169 [
if you want to print entire form then you can use PrintForm control from Visual Basic PowerPacks toolbox.

link for same http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=25169[^]


请检查此链接以供参考
http://social.msdn.microsoft.com/Forums/zh/csharpgeneral/thread/eb80fbbe-6b89-4c3d-9ede-88a2b105c714 [
Hi check this link for reference
http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/eb80fbbe-6b89-4c3d-9ede-88a2b105c714[^]

hope it helps


查看以下代码:
protected void btnPrint_Click(object sender, EventArgs e)
{
	PrintDocument pd = new PrintDocument();
	pd.PrintPage += new PrintPageEventHandler(GetImage);
	pd.Print();      
}
void GetImage(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);    
 }