# PageNumberField Class

> The PageNumberField class represents a field in a header or footer of a Text Control document that automatically displays the current page number. The class inherits all properties and methods from the TextField class. Additionally it implements the properties in the following list. For more information see the technical article Text Fields and Hypertext Links.

- **Product:** TX Text Control .NET for WPF
- **Section:** Reference
- **Kind:** Class
- **Namespace:** `TXTextControl`
- **Package:** `TXTextControl.TextControl.WPF.SDK` (assembly `TXTextControl.dll`, from the private NuGet feed or Text Control Offline Packages)
- **.NET Framework:** reference `TXTextControl.dll` from the setup
- **Inherits:** `TXTextControl.TextField`
- **Path:** TX Text Control .NET for WPF > Reference > TXTextControl > PageNumberField Class
- **2797 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/pagenumberfield/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/pagenumberfield/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/pagenumberfield/llms-full.txt

---

### Description

The PageNumberField class represents a field in a header or footer of a Text Control document that automatically displays the current page number. The class inherits all properties and methods from the [TextField](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/textfield/llms-full.txt) class. Additionally it implements the properties in the following list. For more information see the technical article Text Fields and Hypertext Links.

### Syntax

```csharp
public class PageNumberField : TextField
```

```vbnet
Public Class PageNumberField
    Inherits TextField
```

### Examples

The following example shows how to add a page number field to a header.

```csharp
textControl1.ViewMode = TXTextControl.ViewMode.PageView;

textControl1.Sections.GetItem().HeadersAndFooters.Add(
    TXTextControl.HeaderFooterType.Header);
TXTextControl.HeaderFooter header = 
    textControl1.Sections.GetItem().HeadersAndFooters.GetItem(
    TXTextControl.HeaderFooterType.Header);

header.Selection.Text = "Page ";
header.PageNumberFields.Add(new TXTextControl.PageNumberField(
    1, TXTextControl.NumberFormat.ArabicNumbers));
```

```vbnet
TextControl1.ViewMode = TXTextControl.ViewMode.PageView

TextControl1.Sections.GetItem().HeadersAndFooters.Add( _
    TXTextControl.HeaderFooterType.Header)
Dim header As TXTextControl.HeaderFooter = _
    TextControl1.Sections.GetItem().HeadersAndFooters.GetItem( _
    TXTextControl.HeaderFooterType.Header)

header.Selection.Text = "Page "
header.PageNumberFields.Add(New TXTextControl.PageNumberField( _
    1, TXTextControl.NumberFormat.ArabicNumbers))
```

The following example creates a current-page field and inserts it into the document footer.

```csharp
textControl.HeadersAndFooters.Add(HeaderFooterType.Footer);
HeaderFooter footer = textControl.HeadersAndFooters.GetItem(HeaderFooterType.Footer);
PageNumberField pageNumberField = new(1, NumberFormat.ArabicNumbers);
footer.PageNumberFields.Add(pageNumberField);
```

```vbnet
textControl.HeadersAndFooters.Add(HeaderFooterType.Footer)
Dim footer As HeaderFooter = textControl.HeadersAndFooters.GetItem(HeaderFooterType.Footer)
Dim pageNumberField As New PageNumberField(1, NumberFormat.ArabicNumbers)
footer.PageNumberFields.Add(pageNumberField)
```

---

## In This Section

- [PageNumberField Constructor](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/pagenumberfield/constructor/llms-full.txt): Creates a new instance of the PageNumberField class.
- [PageNumberField.NumberFormat Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/pagenumberfield/numberformat-property/llms-full.txt): Gets or sets the number format. The property's value is a member of the NumberFormat enumeration.
- [PageNumberField.PageNumberDialog Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/pagenumberfield/pagenumberdialog-method/llms-full.txt): Opens a dialog box to alter the formatting and numbering attributes of the page number field.
- [PageNumberField.ShowNumberOfPages Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/pagenumberfield/shownumberofpages-property/llms-full.txt): Gets or sets a value indicating whether the field shows the page number or the total number of pages.
- [PageNumberField.StartNumber Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/pagenumberfield/startnumber-property/llms-full.txt): Gets or sets the page number for the first page.

---

## Nearby

- **Previous:** [PageMargins.Top Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/pagemargins/top-property/llms-full.txt)
- **Next:** [PageNumberField Constructor](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/pagenumberfield/constructor/llms-full.txt)
