Skype:TextControlSupport
Orders:877-462-4772
TX Text Control - word processing components.

Inserting continuous page numbers

Topics for Wednesday, August 18 2004

Inserting continuous page numbers using TX Text Control .NET

Click to enlarge

TX Text Control .NET 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 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:

  1. Dim pageField As New TXTextControl.PageNumberField(1, _
  2. TXTextControl.NumberFormat.ArabicNumbers)

Finally, we insert a header and add the special field to it.

  1. TextControl1.HeadersAndFooters.Add(TXTextControl.HeaderFooterType.Header)
  2.  
  3. With TextControl1.HeadersAndFooters.GetItem(TXTextControl.HeaderFooterType.Header)
  4. .Selection.Text = "Page of "
  5. .Selection.Start = 5
  6. .PageNumberFields.Add(pageField)
  7. .Selection.Start = 9
  8. .TextFields.Add(curPages)
  9. 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 returns the required value.

  1. curPages.Text = TextControl1.Pages

Please download Download [7.71 KB, ZIP] the full source code for this sample.

The minimum requirements for this sample application are TX Text Control .NET trial version and Visual Studio .NET 2003.

top

Top 10 Bestselling Product Award 2007Top 25 Publisher Product Award 2007Top 10 Bestselling Product Award 2007 in JapanTop 25 Bestselling Product Award 2006Top 25 Bestselling Publisher Award 2006Reader's Choice Award, dot.net magazin, 3rd place