private static void OnGridBeforePrint(object sender, Infragistics.Win.UltraWinGrid.CancelablePrintEventArgs e) { //Event handler when after a print job has been initaited and configured by a user, just before data is sent to the printer if (UltraGridPrinter.ShowDialog) { //Configure printer properties page PrintDialog dlg = new PrintDialog(); dlg.UseEXDialog = true; dlg.AllowPrintToFile = dlg.AllowSelection = dlg.AllowSomePages = false; dlg.Document = e.PrintDocument; //dlg.PrinterSettings = e.PrintDocument.PrinterSettings; if (dlg.ShowDialog() == DialogResult.OK) { e.Cancel = false; } else { e.Cancel = true; } } else { e.Cancel = false; } }
private static void OnGridBeforePrint(object sender, Infragistics.Win.UltraWinGrid.CancelablePrintEventArgs e) { //Event handler when after a print job has been initaited and configured by //a user, just before data is sent to the printer PrintDialog dlg = null; DialogResult res; try { if (UltraGridPrinter.ShowDialog) { //Configure printer properties page dlg = new PrintDialog(); dlg.AllowPrintToFile = dlg.AllowSelection = dlg.AllowSomePages = false; dlg.Document = e.PrintDocument; //dlg.PrinterSettings = e.PrintDocument.PrinterSettings; res = dlg.ShowDialog(); if (res == DialogResult.OK) { //Retain current settings and print e.Cancel = false; } else { e.Cancel = true; } } else { e.Cancel = false; } } catch (Exception ex) { throw ex; } }
private static void OnGridInitializePrint(object sender, Infragistics.Win.UltraWinGrid.CancelablePrintEventArgs e) { //Event handler when a print job is first initiated UltraGrid grid = (UltraGrid)sender; setLogicalPageLayout(grid, e.DefaultLogicalPageLayoutInfo); e.PrintDocument.DocumentName = grid.Text; e.PrintDocument.DefaultPageSettings = UltraGridSvc.Settings; }
private static void OnGridInitializePrint(object sender, Infragistics.Win.UltraWinGrid.CancelablePrintEventArgs e) { //Event handler when a print job is first initiated UltraGrid grid = (UltraGrid)sender; e.PrintLayout.Override.RowSelectors = DefaultableBoolean.False; e.PrintLayout.BorderStyle = UIElementBorderStyle.None; e.PrintLayout.Scrollbars = Scrollbars.None; setLogicalPageLayout(grid, e.DefaultLogicalPageLayoutInfo); e.PrintDocument.DocumentName = grid.Text; e.PrintDocument.DefaultPageSettings = UltraGridPrinter.Settings; }
private static void OnGridInitializePrint(object sender, Infragistics.Win.UltraWinGrid.CancelablePrintEventArgs e) { //Event handler when a print job is first initiated UltraGrid oGrid = (UltraGrid)sender; try { //Set layout attributes setLogicalPageLayout(oGrid, e.DefaultLogicalPageLayoutInfo); //Set print document attributes including defualt page settings e.PrintDocument.DocumentName = oGrid.Text; e.PrintDocument.DefaultPageSettings = UltraGridSvc.Settings; } catch (Exception ex) { throw ex; } }
private static void OnGridBeforePrint(object sender, Infragistics.Win.UltraWinGrid.CancelablePrintEventArgs e) { //Event handler when after a print job has been initaited and configured by //a user, just before data is sent to the printer PrintDialog dlg = null; DialogResult res; try { if (UltraGridSvc.ShowDialog) { //Configure printer properties page dlg = new PrintDialog(); dlg.AllowPrintToFile = dlg.AllowSelection = dlg.AllowSomePages = false; dlg.Document = e.PrintDocument; //dlg.PrinterSettings = e.PrintDocument.PrinterSettings; res = dlg.ShowDialog(); if (res == DialogResult.OK) { //Retain current settings and print #region Debug Debug.Write("dlg.Document.PrinterSettings.PrinterName=" + dlg.Document.PrinterSettings.PrinterName + "\n"); Debug.Write("dlg.Document.PrinterSettings.DefaultPageSettings.Margins.Left=" + dlg.Document.PrinterSettings.DefaultPageSettings.Margins.Left.ToString() + "\n"); Debug.Write("dlg.Document.PrinterSettings.DefaultPageSettings.Landscape=" + dlg.Document.PrinterSettings.DefaultPageSettings.Landscape.ToString() + "\n"); Debug.Write("dlg.Document.DefaultPageSettings.Margins.Left=" + dlg.Document.DefaultPageSettings.Margins.Left.ToString() + "\n"); Debug.Write("dlg.Document.DefaultPageSettings.Landscape=" + dlg.Document.DefaultPageSettings.Landscape.ToString() + "\n"); Debug.Write("e.PrintDocument.PrinterSettings.PrinterName=" + e.PrintDocument.PrinterSettings.PrinterName + "\n"); Debug.Write("e.PrintDocument.PrinterSettings.DefaultPageSettings.Margins.Left=" + e.PrintDocument.PrinterSettings.DefaultPageSettings.Margins.Left.ToString() + "\n"); Debug.Write("e.PrintDocument.PrinterSettings.DefaultPageSettings.Landscape=" + e.PrintDocument.PrinterSettings.DefaultPageSettings.Landscape.ToString() + "\n"); Debug.Write("e.PrintDocument.DefaultPageSettings.Margins.Left=" + e.PrintDocument.DefaultPageSettings.Margins.Left.ToString() + "\n"); Debug.Write("e.PrintDocument.DefaultPageSettings.Landscape=" + e.PrintDocument.DefaultPageSettings.Landscape.ToString() + "\n"); #endregion e.Cancel = false; } else { e.Cancel = true; } } else { e.Cancel = false; } } catch (Exception ex) { throw ex; } }
private static void OnGridInitializePrint(object sender, Infragistics.Win.UltraWinGrid.CancelablePrintEventArgs e) { //Event handler when a print job is first initiated UltraGrid oGrid = (UltraGrid)sender; try { //Set layout attributes setLogicalPageLayout(oGrid, e.DefaultLogicalPageLayoutInfo); //Set print document attributes including defualt page settings e.PrintDocument.DocumentName = oGrid.Text; e.PrintLayout.Override.RowSelectors = DefaultableBoolean.False; e.PrintLayout.BorderStyle = UIElementBorderStyle.None; e.PrintLayout.Scrollbars = Scrollbars.None; e.PrintDocument.DefaultPageSettings = UltraGridPrinter.Settings; } catch (Exception ex) { throw ex; } }
private void ultraGrid1_InitializePrint(object sender, Infragistics.Win.UltraWinGrid.CancelablePrintEventArgs e) { Helper.PrintDisplay(e, "云南人才市场会员档案报表"); }
private void SetupPrint(Infragistics.Win.UltraWinGrid.CancelablePrintEventArgs e) { //set the previewinfo values based on the values selected in // the controls on the form try { e.DefaultLogicalPageLayoutInfo.FitWidthToPages = _Settings.FitToPages; // e.DefaultLogicalPageLayoutInfo.PageHeaderAppearance.Image = if (_Settings.IncludeImage) { e.DefaultLogicalPageLayoutInfo.PageHeaderAppearance.Image = Image.FromFile(VWAPath.ViewWasteBackgroundImage); e.DefaultLogicalPageLayoutInfo.PageHeaderAppearance.ImageHAlign = HAlign.Left; } e.DefaultLogicalPageLayoutInfo.PageHeader = _Settings.Title; if (_Settings.AllPages) { e.PrintDocument.PrinterSettings.PrintRange = System.Drawing.Printing.PrintRange.AllPages; } else if (_Settings.CurrentPage) { e.PrintDocument.PrinterSettings.PrintRange = System.Drawing.Printing.PrintRange.CurrentPage; } else { e.PrintDocument.PrinterSettings.PrintRange = System.Drawing.Printing.PrintRange.SomePages; e.PrintDocument.PrinterSettings.FromPage = _Settings.PagesFrom * Math.Max(_Settings.FitToPages, 1) - 1; e.PrintDocument.PrinterSettings.ToPage = _Settings.PagesTo * Math.Max(_Settings.FitToPages, 1); } } catch { e.PrintDocument.PrinterSettings.PrintRange = System.Drawing.Printing.PrintRange.AllPages; } // hide row selector column e.PrintLayout.Bands["Weights"].Override.RowSelectors = DefaultableBoolean.False; // activate key fields for editing to apply the same style for all columns e.PrintLayout.Bands["Weights"].Columns["ID"].CellActivation = Activation.AllowEdit; e.PrintLayout.Bands["Weights"].Columns["TransKey"].CellActivation = Activation.AllowEdit; e.PrintLayout.Bands["Weights"].Columns["WasteCost"].CellActivation = Activation.AllowEdit; // -------------------------------------------------------------------------------- // Print settings // -------------------------------------------------------------------------------- e.DefaultLogicalPageLayoutInfo.PageHeaderHeight = 40; e.DefaultLogicalPageLayoutInfo.PageHeaderAppearance.FontData.Bold = Infragistics.Win.DefaultableBoolean.True; e.DefaultLogicalPageLayoutInfo.PageHeaderAppearance.TextHAlign = Infragistics.Win.HAlign.Center; e.DefaultLogicalPageLayoutInfo.PageHeaderAppearance.FontData.SizeInPoints = 20; //For Columns to be not get clipped e.DefaultLogicalPageLayoutInfo.ClippingOverride = ClippingOverride.No; e.DefaultLogicalPageLayoutInfo.ColumnClipMode = ColumnClipMode.RepeatClippedColumns; e.PrintLayout.Override.RowSizing = RowSizing.Free; // Following code takes a lot of time - it resizes cells with scrolling to display their content on the page //foreach (UltraGridRow row in e.PrintLayout.Rows) // row.PerformAutoSize(); // Use <#> token in the string to designate page numbers. e.DefaultLogicalPageLayoutInfo.PageFooter = "Page <#>."; e.DefaultLogicalPageLayoutInfo.PageFooterHeight = 40; e.DefaultLogicalPageLayoutInfo.PageFooterAppearance.TextHAlign = HAlign.Right; e.DefaultLogicalPageLayoutInfo.PageFooterAppearance.FontData.Italic = DefaultableBoolean.True; e.DefaultLogicalPageLayoutInfo.PageFooterBorderStyle = UIElementBorderStyle.Solid; }