Inserting MS Word Compatible Page Number Fields
TX Text Control X9 introduced a new ready-to-use dialog and context menus to insert and manipulate page numbers. Additionally, a new type of page numbers has been implemented to show the total number of pages. This page number field is updated automatically when pages are added or removed. These fields are completely compatible to MS Word and can be exported and imported to and from DOC, DOCX or RTF. For each section in the document, page numbers can either be continued from the previous…


TX Text Control X9 introduced a new ready-to-use dialog and context menus to insert and manipulate page numbers. Additionally, a new type of page numbers has been implemented to show the total number of pages. This page number field is updated automatically when pages are added or removed.

These fields are completely compatible to MS Word and can be exported and imported to and from DOC, DOCX or RTF.
For each section in the document, page numbers can either be continued from the previous section or can be restarted with a certain start number.
The new dialog can be used to change the type of the page number field and to adjust the number format and the section behavior.
The following C# code shows how to insert a new header and two page number fields. The first field shows the current page number and the second field represents the total number of pages in the document.
textControl1.Sections.GetItem().HeadersAndFooters.Add(
TXTextControl.HeaderFooterType.Header);
HeaderFooter hfHeader =
textControl1.Sections.GetItem().HeadersAndFooters.GetItem(
HeaderFooterType.Header);
PageNumberField currentPageNumber =
new PageNumberField(1, NumberFormat.ArabicNumbers);
hfHeader.PageNumberFields.Add(currentPageNumber);
hfHeader.Selection.Text = " of ";
PageNumberField totalPageNumbers = new PageNumberField();
totalPageNumbers.ShowNumberOfPages = true;
hfHeader.PageNumberFields.Add(totalPageNumbers);
The following screenshot shows the page number fields in the inserted page header:

Start today and download a fully featured, 30 day trial version
Related Posts
Create a Table of Contents in Windows Forms using C#
This article explains how to create a table of contents in Windows Forms using the ribbon or programmatically. Creating a table of contents is required to organize large documents.
Official TX Text Control .NET Sample Applications Are Now Hosted on GitHub
This article gives a quick overview of the new repositories, their structure and our plans for the future.
ASP.NETJavaScriptDocument Editor
Detect Toggle Button Changes Using a MutationObserver
This article shows how to detect changes of toggle buttons in the ribbon of the web editor using a MutationObserver. The state of a toggle button in the ribbon visualizes the state of a certain…
Two Ways to Restart Numbered Lists in TX Text Control
In TX Text Control, numbered lists are continued by default and need to be reset when required. There is more than one way if you want to restart numbered lists in a document. In this article, two…
Zoom Tricks: Disabling CTRL + MOUSE WHEEL and More
This article shows how to disable CTRL + MOUSE WHEEL, implement zooming with keyboard and reset the zoom factor to its default value.