When you print a report using UltraWinGrid, you may find that the data from the grid does not easily fit onto a single sheet of paper. Although this is usually because there are too many rows to fit vertically, it is also possible that your data consists of too many columns to fit horizonatally. For this reason, the control must sometimes make a distinction between a single "logical" page and the "physical" page (or sheets of paper) that may be required to print it. Essentially, logical pages break only on row boundaries. If you print a report with enough columns to fill the widths of three sheets of paper, the first logical page will comprise three physical pages.
The FitWidthToPages property limits the number of physical pages that a report may span. The default value for this property is 0, which indicates that the report may span as many physical pages are required to print all of the columns. If you set this property to a non-zero value, the control will scale the output so that the columns in the report will fit onto the specified number of pages. Note that scaling is proportional; if the data is reduced in width to fit, it will also be reduced in height, resulting in smaller print and more rows on each page.
Imports Infragistics.Shared Imports Infragistics.Win Imports Infragistics.Win.UltraWinGrid Private Sub UltraGrid1_InitializePrintPreview(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.CancelablePrintPreviewEventArgs) Handles ultraGrid1.InitializePrintPreview ' Set the zomm level to 100 % in the print preview. e.PrintPreviewSettings.Zoom = 1.0 ' Set the location and size of the print preview dialog. e.PrintPreviewSettings.DialogLeft = SystemInformation.WorkingArea.X e.PrintPreviewSettings.DialogTop = SystemInformation.WorkingArea.Y e.PrintPreviewSettings.DialogWidth = SystemInformation.WorkingArea.Width e.PrintPreviewSettings.DialogHeight = SystemInformation.WorkingArea.Height ' Horizontally fit everything in a signle page. e.DefaultLogicalPageLayoutInfo.FitWidthToPages = 1 ' Set up the header and the footer. e.DefaultLogicalPageLayoutInfo.PageHeader = "Title" e.DefaultLogicalPageLayoutInfo.PageHeaderHeight = 40 e.DefaultLogicalPageLayoutInfo.PageHeaderAppearance.FontData.SizeInPoints = 14 e.DefaultLogicalPageLayoutInfo.PageHeaderAppearance.TextHAlign = HAlign.Center e.DefaultLogicalPageLayoutInfo.PageHeaderBorderStyle = UIElementBorderStyle.Solid ' 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 ' Set the ClippingOverride to Yes. e.DefaultLogicalPageLayoutInfo.ClippingOverride = ClippingOverride.Yes ' Set the document name through the PrintDocument which returns a PrintDocument object. e.PrintDocument.DocumentName = "Document Name" End Sub
using Infragistics.Shared; using Infragistics.Win; using Infragistics.Win.UltraWinGrid; using System.Diagnostics; private void ultraGrid1_InitializePrintPreview(object sender, Infragistics.Win.UltraWinGrid.CancelablePrintPreviewEventArgs e) { // Set the zomm level to 100 % in the print preview. e.PrintPreviewSettings.Zoom = 1.0; // Set the location and size of the print preview dialog. e.PrintPreviewSettings.DialogLeft = SystemInformation.WorkingArea.X; e.PrintPreviewSettings.DialogTop = SystemInformation.WorkingArea.Y; e.PrintPreviewSettings.DialogWidth = SystemInformation.WorkingArea.Width; e.PrintPreviewSettings.DialogHeight = SystemInformation.WorkingArea.Height; // Horizontally fit everything in a signle page. e.DefaultLogicalPageLayoutInfo.FitWidthToPages = 1; // Set up the header and the footer. e.DefaultLogicalPageLayoutInfo.PageHeader = "Title"; e.DefaultLogicalPageLayoutInfo.PageHeaderHeight = 40; e.DefaultLogicalPageLayoutInfo.PageHeaderAppearance.FontData.SizeInPoints = 14; e.DefaultLogicalPageLayoutInfo.PageHeaderAppearance.TextHAlign = HAlign.Center; e.DefaultLogicalPageLayoutInfo.PageHeaderBorderStyle = UIElementBorderStyle.Solid; // 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; // Set the ClippingOverride to Yes. e.DefaultLogicalPageLayoutInfo.ClippingOverride = ClippingOverride.Yes; // Set the document name through the PrintDocument which returns a PrintDocument object. e.PrintDocument.DocumentName = "Document Name"; }
Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2