TX Text Control .NET for Windows Forms has a special marked text field - the page number field. It is inserted into a header or a footer and automatically displays the current page number on every page. Additionally, you could insert a field which displays the total number of pages like "Page X of Y".
TX Text Control .NET for Windows Forms provides the PageNumberField, which can be initialized with a starting page number and the format of the numbering. Possible values are:
ArabicNumbers, Letters, CapitalLetters, RomanNumbers and SmallRomanNumbers.
The field will be constructed like this:
Dim pageField As New TXTextControl.PageNumberField(1, _
TXTextControl.NumberFormat.ArabicNumbers)
Finally, we insert a header and add the special field to it.
TextControl1.HeadersAndFooters.Add(TXTextControl.HeaderFooterType.Header)
With TextControl1.HeadersAndFooters.GetItem(TXTextControl.HeaderFooterType.Header)
.Selection.Text = "Page of "
.Selection.Start = 5
.PageNumberFields.Add(pageField)
.Selection.Start = 9
.TextFields.Add(curPages)
End With
The curPages field is a normal TextField of TX Text Control, which will be updated with the total number of pages in the Changed event. The Pages property of TX Text Control .NET for Windows Forms returns the required value.
curPages.Text = TextControl1.Pages
The minimum requirements for this sample application are TX Text Control .NET for Windows Forms trial version and Visual Studio .NET 2003.
Best regards
The Newsletter Team