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.
Hi,
If I recall correctly, you separate the sections by using the tab character.
So in VB, it would be something like this:
e.DefaultLogicalPageLayoutInfo.PageHeader = DateTime.Now + vbTab + "Stock Details" + vbTab + "Bin"
or in C#:
e.DefaultLogicalPageLayoutInfo.PageHeader = DateTime.Now + \tStock Details\t" + "Bin"
Hi
How to print multi texts in header.
Like
Header 1( Stock details - center aligned)
Header 2 (Date: Left aligned)
Header 3 (Bin: Right aligned)
using the line
e.DefaultLogicalPageLayoutInfo.PageHeader = "Stock Details"
i able to print only one header
How do you actually prind a WinGrid onto UltraPrintDocument and not an UltraGridPrintDocument; is it possible?
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.