Hello, is there a way where someone can print a grid with headers and footers for print preview dialog. I have used the UltraGridPrintDocument but it only prints the contents of the grid. I would like to be able to add a header so users know what data the grid is showing plus images and stuff like that. Does anyone have any ideas?? It would be appreciated. Below is an image of what I am trying to accomplish.
Hey did u get the solution
i am looking for the same one.
Hi patel,
Below is the code as you requested for,,,,
just use the method Grid.printpreview and then in initialize event play with these properties..
grd_InitializePrintPreview
e.DefaultLogicalPageLayoutInfo.PageHeaderAppearance.FontData.SizeInPoints = 12
e.DefaultLogicalPageLayoutInfo.PageHeaderAppearance.TextHAlign = HAlign.Left
e.DefaultLogicalPageLayoutInfo.PageHeader = "Page Heade"
''for summary row
e.PrintLayout.Override.SummaryFooterSpacingAfter = 30
e.PrintLayout.Override.SummaryFooterSpacingBefore = 20
e.PrintLayout.Bands(0).Summaries.Clear()
e.PrintLayout.Override.SummaryFooterCaptionVisible = DefaultableBoolean.True
e.PrintLayout.Bands(0).SummaryFooterCaption = "ur text"
e.PrintLayout.Override.ColumnSizingArea = ColumnSizingArea.EntireColumn
e.PrintLayout.Override.ColumnAutoSizeMode = ColumnAutoSizeMode.VisibleRows
''COLUMNS TO BE HIDDEN
.Bands(0).Columns("Select").Hidden = True
.Bands(0).Columns("hidden1").Hidden = True
End With
''COLUMN SIZE SETTING
.Bands(0).Columns("col1").Width = 40
.Bands(0).Columns("col2").Width = 60
''print preview dialog box size settings
e.PrintPreviewSettings.DialogWidth = Me.Width - 5
''page zoom level
e.PrintPreviewSettings.Zoom = 1.0
e.DefaultLogicalPageLayoutInfo.PageHeaderAppearance.ForeColor = Color.Maroon
e.DefaultLogicalPageLayoutInfo.PageHeaderHeight = 20
e.DefaultLogicalPageLayoutInfo.PageHeaderAppearance.TextVAlign = Infragistics.Win.VAlign.Middle
e.DefaultLogicalPageLayoutInfo.PageHeaderAppearance.TextHAlign = Infragistics.Win.HAlign.Left
e.PrintPreviewSettings.DialogCaption = "Print Preview header customize"
''additional columns
e.PrintLayout.Bands(0).Columns.Add("PrintAddColumn2")
e.PrintDocument.DefaultPageSettings.Margins.Right = 0
e.PrintDocument.DefaultPageSettings.Margins.Top = 0
e.PrintDocument.DefaultPageSettings.Margins.Bottom = 0
e.PrintDocument.DefaultPageSettings.Landscape = True
e.PrintLayout.AutoFitStyle = AutoFitStyle.ResizeAllColumns
e.PrintLayout.Bands(0).Override.HeaderPlacement = HeaderPlacement.RepeatOnBreak
e.PrintLayout.Override.HeaderAppearance = Nothing
' e.PrintLayout.Override.HeaderStyle = HeaderStyle.Default
e.DefaultLogicalPageLayoutInfo.FitWidthToPages = 1
Yeah, there are two ways you can set the text for headers and footers. What you do is catch the InitializePrint event of the grid and the event args will contain the layout and page layout info objects wchih you can modify. That the other way is to catch the PageHeaderPrinting and PageFooterPrinting events of the UltraGridPrintDocument object. And that should do it so that you can set text.