private void btnPrint_Click(object sender, EventArgs e) { PrintableComponentLink pcl = new PrintableComponentLink(new PrintingSystem()); pcl.Component = layoutControlPrint; pcl.PaperKind = System.Drawing.Printing.PaperKind.A4; pcl.Landscape = true; pcl.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0); pcl.PrintDlg(); }
private void btnPrint_ElementClick(object sender, DevExpress.XtraBars.Navigation.NavElementEventArgs e) { PrintableComponentLink link = new PrintableComponentLink(new PrintingSystem()); link.Component = gcStoklar; link.PrintingSystem.Document.AutoFitToPagesWidth = 1; link.PaperKind = System.Drawing.Printing.PaperKind.A4; link.Landscape = false; link.PrintDlg(); }
private void BtnPrintClicked(object sender, EventArgs e) { if (transactionGrid.DataSource == null) { XtraMessageBox.Show("Select the BinCard to Print", "Select Bincard", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if (tabControl1.SelectedTabPage == tbSOHLocation) { PrintableComponentLink pcl = new PrintableComponentLink(new PrintingSystem()); pcl.Component = gridLocations; pcl.Landscape = true; Item itm = new Item(); itm.GetItemById(_ItemID); pcl.RtfReportHeader = "Locations For: " + itm.FullItemName + "\n"; pcl.RtfReportFooter = DateTimeHelper.ServerDateTime.ToShortDateString(); pcl.PrintDlg(); } else if (tabControl1.SelectedTabPage == tbSOHPriceSummary) { PrintableComponentLink pcl = new PrintableComponentLink(new PrintingSystem()); pcl.Component = gridSOHSummary; pcl.Landscape = true; Item itm = new Item(); itm.GetItemById(_ItemID); pcl.RtfReportHeader = "Price Summary For: " + itm.FullItemName + "\n"; pcl.RtfReportFooter = DateTimeHelper.ServerDateTime.ToShortDateString(); pcl.PrintDlg(); } else { PrintableComponentLink pcl = new PrintableComponentLink(new PrintingSystem()); pcl.Component = transactionGrid; pcl.Landscape = true; Item itm = new Item(); itm.GetItemById(_ItemID); pcl.RtfReportHeader = "Transactions For: " + itm.FullItemName + "\n"; pcl.RtfReportFooter = DateTimeHelper.ServerDateTime.ToShortDateString(); pcl.PrintDlg(); } }
/// <summary> /// 打印Grid /// </summary> /// <param name="gridControl">The grid control.</param> /// <param name="printSetting">The print setting.</param> /// <param name="showPreview">if set to <c>true</c> 打印预览.</param> /// 创建时间:2015-05-26 11:26 /// 备注说明:<c>null</c> public static void CustomPrint(this GridControl gridControl, PrintItem printSetting, bool showPreview) { using (PrintableComponentLink _print = new PrintableComponentLink(new PrintingSystem())) { _print.Component = gridControl; _print.Landscape = true; _print.PaperKind = printSetting.PaperKind; CustomPrintHeader(gridControl, _print, printSetting); CustomPrintFooter(gridControl, _print, printSetting); _print.CreateDocument(); if (showPreview) { _print.ShowPreview(); } else { _print.PrintDlg(); } } }
private void btnPrint_Click(object sender, EventArgs e) { // Print the gridControl1. printableComponentLink1.PrintDlg(); }
public void PrintGrid(DevExpress.XtraGrid.GridControl gc, bool printPreview) { //GridView gvwContact = (GridView) gc.DefaultView; // string strHeader = strMenuOption; //strHeader = strHeader.Remove(strHeader.Length - 3, 3); //strHeader += " Information"; PageHeaderFooter phf = new PageHeaderFooter(); phf.Header.Font = new Font("Arial", 15, FontStyle.Bold, GraphicsUnit.Point); string str = ""; phf.Header.LineAlignment = BrickAlignment.Near; str = "Payroll By Instructor"; // str.AppendFormat(Environment.NewLine); //Page header = phf.Header; phf.Header.Content.Add(str); // str.AppendFormat("Date Generated: {0}", System.DateTime.Today.ToShortDateString()); //str.AppendFormat(Environment.NewLine); if (checkEdit1.Checked && checkEdit2.Checked) str = dateEditStartDate.DateTime.ToShortDateString() + " - " + dateEditEndDate.DateTime.ToShortDateString(); else if (checkEdit1.Checked && !checkEdit2.Checked) { str = dateEditStartDate.DateTime.ToLongDateString() + " - Unlimited"; } else if (!checkEdit1.Checked && checkEdit2.Checked) { str = "Unlimited - " + dateEditEndDate.DateTime.ToShortDateString(); } else { str = ""; //str.AppendFormat("From: Not Filtered To: Not Filtered"); } phf.Header.LineAlignment = BrickAlignment.Center; phf.Header.Content.Add(str); phf.Footer.LineAlignment = BrickAlignment.Near; phf.Footer.Content.Add(""); phf.Footer.LineAlignment = BrickAlignment.Center; phf.Footer.Content.Add(""); phf.Footer.LineAlignment = BrickAlignment.Far; String footer = "Date Generated: " + System.DateTime.Today.ToShortDateString(); phf.Footer.Content.Add(footer); phf.Footer.LineAlignment = BrickAlignment.Far; PrintableComponentLink _link = new PrintableComponentLink(new PrintingSystem()); _link.Component = gc; _link.Landscape = true; _link.PageHeaderFooter = phf; _link.PaperKind = System.Drawing.Printing.PaperKind.A4; _link.Margins.Top = 60; _link.Margins.Bottom = 60; _link.Margins.Right = 10; _link.Margins.Left = 10; if (printPreview) _link.ShowPreviewDialog(); else _link.PrintDlg(); /* PrinterSettings settings = printDocument1.PrinterSettings; //Set PageSize to 'A4' bool found=false; foreach (PaperSize size in settings.PaperSizes) { if (size.PaperName == "A4, 210x297 mm") found = true; if (found) { settings.DefaultPageSettings.PaperSize = size; break; } else continue; } printDocument1.DefaultPageSettings.Landscape = true; printDocument1.DefaultPageSettings.Margins = new Margins(50, 50, 15, 50); //printDocument1.DefaultPageSettings.PaperSize = new PaperSize("A4, 210x297 mm", 827, 1169); dataGridPrinter1 = new GridViewPrinter(gc, printDocument1, gvwContact); dataGridPrinter1.PageNumber = 1; dataGridPrinter1.RowCount = 0; if (printPreviewDialog1.ShowDialog() == DialogResult.OK) { }*/ }
public void PrintGrid(DevExpress.XtraGrid.GridControl gc, bool printPreview) { //GridView gvwContact = (GridView) gc.DefaultView; // string strHeader = strMenuOption; //strHeader = strHeader.Remove(strHeader.Length - 3, 3); //strHeader += " Information"; PageHeaderFooter phf = new PageHeaderFooter(); phf.Header.Font = new Font("Arial", 15, FontStyle.Bold, GraphicsUnit.Point); string str = ""; phf.Header.LineAlignment = BrickAlignment.Near; str = "Pay Details By Instructor"; // str.AppendFormat(Environment.NewLine); //Page header = phf.Header; phf.Header.Content.Add(str); // str.AppendFormat("Date Generated: {0}", System.DateTime.Today.ToShortDateString()); //str.AppendFormat(Environment.NewLine); if (checkEdit1.Checked && checkEdit2.Checked) { str = dateEditStartDate.DateTime.ToShortDateString() + " - " + dateEditEndDate.DateTime.ToShortDateString(); } else if (checkEdit1.Checked && !checkEdit2.Checked) { str = dateEditStartDate.DateTime.ToLongDateString() + " - Unlimited"; } else if (!checkEdit1.Checked && checkEdit2.Checked) { str = "Unlimited - " + dateEditEndDate.DateTime.ToShortDateString(); } else { str = ""; //str.AppendFormat("From: Not Filtered To: Not Filtered"); } phf.Header.LineAlignment = BrickAlignment.Center; phf.Header.Content.Add(str); phf.Footer.LineAlignment = BrickAlignment.Near; phf.Footer.Content.Add(""); phf.Footer.LineAlignment = BrickAlignment.Center; phf.Footer.Content.Add(""); phf.Footer.LineAlignment = BrickAlignment.Far; String footer = "Date Generated: " + System.DateTime.Today.ToShortDateString(); phf.Footer.Content.Add(footer); phf.Footer.LineAlignment = BrickAlignment.Far; PrintableComponentLink _link = new PrintableComponentLink(new PrintingSystem()); _link.Component = gc; _link.Landscape = true; _link.PageHeaderFooter = phf; _link.PaperKind = System.Drawing.Printing.PaperKind.A4; _link.Margins.Top = 60; _link.Margins.Bottom = 60; _link.Margins.Left = 10; _link.Margins.Right = 10; if (printPreview) { _link.ShowPreviewDialog(); } else { _link.PrintDlg(); } /* * PrinterSettings settings = printDocument1.PrinterSettings; * //Set PageSize to 'A4' * bool found=false; * foreach (PaperSize size in settings.PaperSizes) * { * if (size.PaperName == "A4, 210x297 mm") * found = true; * if (found) * { * settings.DefaultPageSettings.PaperSize = size; * break; * } * else continue; * } * * printDocument1.DefaultPageSettings.Landscape = true; * printDocument1.DefaultPageSettings.Margins = new Margins(50, 50, 15, 50); * //printDocument1.DefaultPageSettings.PaperSize = new PaperSize("A4, 210x297 mm", 827, 1169); * * dataGridPrinter1 = new GridViewPrinter(gc, printDocument1, gvwContact); * dataGridPrinter1.PageNumber = 1; * dataGridPrinter1.RowCount = 0; * if (printPreviewDialog1.ShowDialog() == DialogResult.OK) * { * }*/ }
private void BtnPrintClicked(object sender, EventArgs e) { if (transactionGrid.DataSource == null) { XtraMessageBox.Show("Select the BinCard to Print", "Select Bincard", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if (tabControl1.SelectedTabPage == tbSOHLocation) { PrintableComponentLink pcl = new PrintableComponentLink(new PrintingSystem()); pcl.Component = gridLocations; pcl.Landscape = true; Item itm = new Item(); itm.GetItemById(_ItemID); pcl.RtfReportHeader = "Locations For: " + itm.FullItemName + "\n"; pcl.RtfReportFooter = DateTimeHelper.ServerDateTime.ToShortDateString(); pcl.PrintDlg(); } else if (tabControl1.SelectedTabPage == tbSOHPriceSummary) { PrintableComponentLink pcl = new PrintableComponentLink(new PrintingSystem()); pcl.Component = gridSOHSummary; pcl.Landscape = true; Item itm = new Item(); itm.GetItemById(_ItemID); pcl.RtfReportHeader = "Price Summary For: " + itm.FullItemName + "\n"; pcl.RtfReportFooter = DateTimeHelper.ServerDateTime.ToShortDateString(); pcl.PrintDlg(); } else { PrintableComponentLink pcl = new PrintableComponentLink(new PrintingSystem()); pcl.Component = transactionGrid; pcl.Landscape = true; Item itm = new Item(); itm.GetItemById(_ItemID); pcl.RtfReportHeader = "Transactions For: " + itm.FullItemName + "\n"; pcl.RtfReportFooter = DateTimeHelper.ServerDateTime.ToShortDateString(); pcl.PrintDlg(); } }
private void btnPrint_Click(object sender, EventArgs e) { PrintableComponentLink pcl = new PrintableComponentLink(new PrintingSystem()); pcl.Component = layoutControlPrint; pcl.PaperKind = System.Drawing.Printing.PaperKind.A4; pcl.Landscape = true; pcl.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0); pcl.PrintDlg(); }