Devexpress.xtraprinting provides DataGrid, ListView, TreeView control, can be processed directly, huh, huh, cool! Example: // Custom Process Private Void BtnPreview_Click (Object Sender, System.EventArgs E) {// Set Currentcursor = Cursor CurrentCursor = Cursor.current; Cursor.current = Cursors.Waitcursor;
// set the variable printing system DevExpress.XtraPrinting.PrintingSystem ps = new DevExpress.XtraPrinting.PrintingSystem (); // this defines a DataGrid control connection, of course, you can define ListView, TreeView control connection DevExpress.XtraPrintingLinks.DataGridLink printLink = new DevExpress .Xtraprintinglinks.dataGridLink (); // Point print connection to DataGrid1 Print1 PRINTLINK.DATAGRID = DataGrid1; PrintLink.createdocument (PS); // give a title Ps.PreviewForm.Text = "Print DataGrid Control content" Ps.previewform.owner = this; // ok, start printing ps.previewForm.show (); // Restore previous cursor style cursor.current = currentcursor;} How do you feel? If it is very cool? If you can print The document adds a title to a more cool? Hey, this can cost it, and finally find that you can come, ..., count, give a complete function: Private Void PrintDataGrid (DataGrid DataGrid, String PRINTTILE) {// Sets the current cursor style Cursor currentcursor = Cursor.current; cursor.current = Cursors.Waitcursor;
Devexpress.xtraprinting.printingsystem ps; deVexpress.xtraprintinglinks.DataGridLink DGDLINK
ps = new DevExpress.XtraPrinting.PrintingSystem (); dgdLink = new DevExpress.XtraPrintingLinks.DataGridLink (); dgdLink.DataGrid = dataGrid; dgdLink.PageHeaderFooter = new DevExpress.XtraPrinting.PageHeaderFooter (new DevExpress.XtraPrinting.PageHeaderArea (new string [] {"" ", Printtitle,"}, new system.drawing.font ("体 _GB2312", 24f, system.drawing.fontstyle.regular, system.drawing.graphicsUnit.point, ((System.byte) (134) ))), Deformation.brickalignment.far), new devexpress.xtraprinting.pagefooterarea (new string [] {"print date [Date Printed]", "," [Page # of pages #] "} New System.drawing.Font ("Song", 9F, System.drawing.FontStyle.Regular, System.drawing.graphicsUnit.Point, ((System.byte) (134))), DevexPress.xtraprinting.brickalignment.near) ); DGDLINK.CREATEDOCUMENT (PS); // give the display window a title bar ps.previewform.text = "Print DataGrid Control content"; // ok, Start printing ps.previewform.show ();
/ / Restore the previous cursor style curSor.current = CurrentCursor;}