您可以在这里快速查找:


 
您的位置: 编程学习 > asp.net教程 > 200509
文章分类

Java技术
2005: 03 04 05 06 07 08
09 10 11 12
2006: 01 02

Asp.net
2005: 07 08 09 10 11 12
2006: 01 02

VB编程
2006: 02

Asp编程
2005: 11 12
2006: 01 02

C++/VC
2005: 10 11 12
2006: 01 02

Delphi
2005: 12
2006: 01 02

其它

 本文章适合所有读者

收藏Code: Printing a DataGrid (Visual C#)

ncowboy
Code: Printing a DataGrid (Visual C#)
This example demonstrates printing a DataGrid control.

Example
private void printGrid_Click(System.Object sender, System.EventArgs e)

printDocument1.Print();

private void printDocument1_PrintPage(System.Object sender, System.Drawing.Printing.PrintPageEventArgs e)

PaintEventArgs myPaintArgs = new PaintEventArgs(e.Graphics, new Rectangle(new Point(0, 0), this.Size));
this.InvokePaint(dataGrid1, myPaintArgs);

Compiling the Code
This example requires:

A Button control named printGrid with a Click event handler.
A DataGrid control named dataGrid1.
A PrintDocument component named printDocument1 with a PrintPage event handler.
The example code replaces the existing event handlers.

Robust Programming
The following conditions may cause an exception:

You do not have permission to access the printer.
There is no printer installed.
Security
In order to run this example, you must have permission to access the printer.

from:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cscon/html/vclrfcodeprintingdatagridvisualc.asp