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.