Version

PageHeader Property

Returns or sets the text that will be printed at the top of each page.
Syntax
'Declaration
 
Public Property PageHeader As String
public string PageHeader {get; set;}
Remarks

The text you specify for the page header will appear at the top of each physical page. If you want to make changes to the text of the header, you can do so in the InitializeLogicalPrintPage event. This will change the header for the logical page only. (See the UltraGrid.InitializeLogicalPrintPage event topic for a description of the difference between logical and physical pages.)

You can insert the page number in to the text of your page header by using a substitution code. The code will be replaced with the physical page number of the page being printed. To insert the physical page number into the page header, add the following substitution code to the text string you assign to the PageHeader property: <#>

You can choose to include the physical page number, the logical page number or some combination of the two on each page. To insert the physical page number on each page, simply include the substitution code in the text of your page header. To insert the logical page number, you can intitalize a logical page counter variable in the IntializePrint event, then use the InitializeLogicalPrintPage event to increment the counter variable and change the text of the page header to include the new logical page count value.

You can justify individual sections of the page header by specifying a tab-delimited string for the PageHeader property. Text specified will be left-aligned until a tab character is encountered. Text following the first tab character that comes before the second tab character will be centered. Text following the second tab character will be right-aligned. For example, you could right align the entire page header by beginning the text string with two tab characters.

Including a tab character in the header text will override any alignments specified for the header. If no tab characters are included in the text, the default alignment will be used (as determined by the settings of the Appearance object returned by PageHeaderAppearance.)

Example
Following code sets some of the properties available in InitializePrint event.

For an overview of how to handle events in Visual Basic or Visual C#, see Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see Consuming Events in the .NET Framework Developer's Guide.

Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid

  Private Sub UltraGrid1_InitializePrint(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.CancelablePrintEventArgs) Handles ultraGrid1.InitializePrint

      ' One could conditionally set Cancel to true to cancel the printing.
      If Me.CheckBox1.Checked Then
          e.Cancel = True
          Return
      End If

      ' 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_InitializePrint(object sender, Infragistics.Win.UltraWinGrid.CancelablePrintEventArgs e)
{

	// One could conditionally set Cancel to true to cancel the printing.
	if ( this.checkBox1.Checked )
	{
		e.Cancel = true;
		return;
	}

	// 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";

}
Requirements

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

See Also