# PageNumberFieldCollection.Clear Method

> Removes all page number fields contained in the collection from the document.

- **Product:** TX Text Control .NET for WPF
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 13.0
- **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
- **Path:** TX Text Control .NET for WPF > Reference > TXTextControl > PageNumberFieldCollection.Clear Method
- **521 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/pagenumberfieldcollection/clear-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/pagenumberfieldcollection/clear-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/pagenumberfieldcollection/clear-method/llms-full.txt

---

### Description

Removes all page number fields contained in the collection from the document.

### Syntax

```csharp
public void Clear(bool keepText);
```

```vbnet
Public Sub Clear(keepText As Boolean)
```

### Parameters

| Parameter | Description |
|---|---|
| keepText | If this parameter is set to true, all page number fields are removed without deleting their texts. Otherwise, the texts are also deleted. |

### Examples

The following example removes all page-number fields while preserving their displayed text before rebuilding the footer.

```csharp
textControl.HeadersAndFooters.Add(HeaderFooterType.Footer);
HeaderFooter footer = textControl.HeadersAndFooters.GetItem(HeaderFooterType.Footer);
PageNumberFieldCollection fields = footer.PageNumberFields;
fields.Add(new PageNumberField());
fields.Clear(true);
```

```vbnet
textControl.HeadersAndFooters.Add(HeaderFooterType.Footer)
Dim footer As HeaderFooter = textControl.HeadersAndFooters.GetItem(HeaderFooterType.Footer)
Dim fields As PageNumberFieldCollection = footer.PageNumberFields
fields.Add(New PageNumberField())
fields.Clear(True)
```

---

## Nearby

- **Previous:** [PageNumberFieldCollection.Add Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/pagenumberfieldcollection/add-method/llms-full.txt)
- **Next:** [PageNumberFieldCollection.CopyTo Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/pagenumberfieldcollection/copyto-method/llms-full.txt)
