Version

Printing Total Number of Pages

Often it is required to print the total number of pages in a format similar to Page 1of N (N being total number of pages). This is possible with the help of a replacement string (<##> or <Total Pages>) and it can be printed either in the header or footer of the printed document.

The following code can be used to print the total number of pages on a page. Events like ultraGridPrintDocument1_PageHeaderPrinting and ultraGridPrintDocument1_PageFooterPrinting can be handled for this purpose.

In Visual Basic:

'Sets the current page number along with the total number of pages in the footer section
e.Section.TextRight = "Page <#> of <##>"
' e. Section.TextRight = “Page<#>of<Total Pages>.”

In C#:

//Sets the current page number along with the total number of pages in the footer section
e.Section.TextRight = "Page <#> of <##>";
// e. Section.TextRight = "Page<#>of<Total Pages>.”;