# PageNumberFieldCollection Class

> An instance of the PageNumberFieldCollection class contains the page number fields in a header or footer of a Text Control document. Page number fields are represented through objects of the type PageNumberField. An instance of this class can be obtained with the HeaderFooter.PageNumberFields property. The PageNumberFieldCollection class implements the IEnumerable and the ICollection interfaces. 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.TextFieldCollectionBase`
- **Implements:** `System.Collections.ICollection`, `System.Collections.IEnumerable`
- **Path:** TX Text Control .NET for WPF > Reference > TXTextControl > PageNumberFieldCollection Class
- **1493 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/pagenumberfieldcollection/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/pagenumberfieldcollection/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/pagenumberfieldcollection/llms-full.txt

---

### Description

An instance of the PageNumberFieldCollection class contains the page number fields in a header or footer of a Text Control document. Page number fields are represented through objects of the type [PageNumberField](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/pagenumberfield/llms-full.txt). An instance of this class can be obtained with the [HeaderFooter.PageNumberFields](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/headerfooter/pagenumberfields-property/llms-full.txt) property. The PageNumberFieldCollection class implements the IEnumerable and the ICollection interfaces. For more information see the technical article Text Fields and Hypertext Links.

### Syntax

```csharp
public sealed class PageNumberFieldCollection : TextFieldCollectionBase
```

```vbnet
Public NotInheritable Class PageNumberFieldCollection
    Inherits TextFieldCollectionBase
```

### Examples

The following example obtains a footer's page-number collection and builds a “Page X of Y” label.

```csharp
textControl.HeadersAndFooters.Add(HeaderFooterType.Footer);
HeaderFooter footer = textControl.HeadersAndFooters.GetItem(HeaderFooterType.Footer);
PageNumberFieldCollection fields = footer.PageNumberFields;
footer.Selection.Text = "Page ";
fields.Add(new PageNumberField());
footer.Selection.Text = " of ";
fields.Add(new PageNumberField() { ShowNumberOfPages = true });
```

```vbnet
textControl.HeadersAndFooters.Add(HeaderFooterType.Footer)
Dim footer As HeaderFooter = textControl.HeadersAndFooters.GetItem(HeaderFooterType.Footer)
Dim fields As PageNumberFieldCollection = footer.PageNumberFields
footer.Selection.Text = "Page "
fields.Add(New PageNumberField())
footer.Selection.Text = " of "
fields.Add(New PageNumberField() With { .ShowNumberOfPages = True })
```

---

## In This Section

- [PageNumberFieldCollection.Add Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/pagenumberfieldcollection/add-method/llms-full.txt): Inserts a new page number field at the current input position of a header or footer.
- [PageNumberFieldCollection.Clear Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/pagenumberfieldcollection/clear-method/llms-full.txt): Removes all page number fields contained in the collection from the document.
- [PageNumberFieldCollection.CopyTo Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/pagenumberfieldcollection/copyto-method/llms-full.txt): Copies the elements of the collection to an array, starting at a particular index.
- [PageNumberFieldCollection.GetItem Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/pagenumberfieldcollection/getitem-method/llms-full.txt): Gets a particular page number field from the collection.
- [PageNumberFieldCollection.Item Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/pagenumberfieldcollection/item-property/llms-full.txt): Gets the field with the specified number from the collection. The number must be between 1 and Count. In C# this property is the indexer for the PageNumberFieldCollection class.
- [PageNumberFieldCollection.Remove Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/pagenumberfieldcollection/remove-method/llms-full.txt): Removes a page number from a header or footer of a Text control document.

---

## Nearby

- **Previous:** [PageNumberField.StartNumber Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/pagenumberfield/startnumber-property/llms-full.txt)
- **Next:** [PageNumberFieldCollection.Add Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/pagenumberfieldcollection/add-method/llms-full.txt)
