# HeaderFooter.AddUndoUnit Method

> Adds the current state of the header or footer to the undo stack. Programmatic changes performed with the header's or footer's properties and methods are not automatically added to a TextControl's undo stack. Calling this method is not necessary, when the header's or footer's text and/or formatting is changed.

- **Product:** TX Text Control .NET Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 32.0
- **Namespace:** `TXTextControl`
- **Package:** `TXTextControl.TextControl.Core.SDK` (assembly `TXTextControl.Core.dll`, from the private NuGet feed or Text Control Offline Packages)
- **Package:** `TXTextControl.TextControl.ASP.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 Server > Reference > TXTextControl > HeaderFooter.AddUndoUnit Method
- **542 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/headerfooter/addundounit-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/headerfooter/addundounit-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/headerfooter/addundounit-method/llms-full.txt

---

### Description

Adds the current state of the header or footer to the undo stack. Programmatic changes performed with the header's or footer's properties and methods are not automatically added to a TextControl's undo stack. Calling this method is not necessary, when the header's or footer's text and/or formatting is changed.

### Syntax

```csharp
public void AddUndoUnit();
```

```vbnet
Public Sub AddUndoUnit()
```

### Examples

The following example creates a header for the first section and configures its content or layout by using `HeaderFooter.AddUndoUnit`.

```csharp
HeaderFooterCollection headers = textControl.Sections[1].HeadersAndFooters;
headers.Add(HeaderFooterType.Header);
HeaderFooter headerFooter = headers.GetItem(HeaderFooterType.Header);
headerFooter.Selection.Text = "Quarterly report";

headerFooter.AddUndoUnit();
Console.WriteLine("Header Footer is ready for use.");
```

```vbnet
Dim headers As HeaderFooterCollection = textControl.Sections(1).HeadersAndFooters
headers.Add(HeaderFooterType.Header)
Dim headerFooter As HeaderFooter = headers.GetItem(HeaderFooterType.Header)
headerFooter.Selection.Text = "Quarterly report"

headerFooter.AddUndoUnit()
Console.WriteLine("Header Footer is ready for use.")
```

---

## Nearby

- **Previous:** [HeaderFooter.Activate Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/headerfooter/activate-method/llms-full.txt)
- **Next:** [HeaderFooter.ApplicationFields Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/headerfooter/applicationfields-property/llms-full.txt)
