# History

The **RadDocument** class can track the history of any actions taken against its content. In this way it allows an undo and redo functionality to be easily implemented. The history is implemented via the **DocumentHistory** class and the **RadDocument** exposes the **History** property of this type. The **RadRichTextEditor**  automatically adds and removes items from the history, when its API methods get called, but you are allowed to manually work with the history as well.

This topic will explain you how to:

* [Enable-Disable History](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/features/history#enabledisable-history)

* [Clear History](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/features/history#clear-history)

* [Undo-Redo Actions](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/features/history#undoredo-actions)

* [Change History Depth](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/features/history#change-history-depth)

* [Preserv History Using RadDocumentEditor](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/features/history#preserve-history-using-raddocumenteditor)

## Enable/Disable History

You can enable or disable the history for the **RadDocument** via the **Enabled** property of the  **DocumentHistory**.

```C#
this.radRichTextEditor1.Document.History.IsEnabled = false;

```

```VB.NET
Me.radRichTextEditor1.Document.History.IsEnabled = False

```

## Clear History

To clear the history you just have to call the **Clear()** method of the **DocumentHistory** class.

```C#
this.radRichTextEditor1.Document.History.Clear();
        
```

```VB.NET
Me.radRichTextEditor1.Document.History.Clear()

```

## Undo/Redo Actions

To undo and redo some actions, you can call the **Undo()** and **Redo()** methods of the **RadRichTextEditor**.

```C#
private void UndoAction()
{
    this.radRichTextEditor1.Undo();
}

private void RedoAction()
{
    this.radRichTextEditor1.Redo();
}

```

```VB.NET
    Private Sub UndoAction()
        Me.radRichTextEditor1.Undo()
    End Sub

    Private Sub RedoAction()
        Me.radRichTextEditor1.Redo()
    End Sub

```

## Change History Depth

To change the history capacity you have to set the desired value of the **Depth** property of the **DocumentHistory**. The default one is **1000**.

```C#
this.radRichTextEditor1.Document.History.Depth = 500;
        
```

```VB.NET
Me.radRichTextEditor1.Document.History.Depth = 500

```

## Preserve History Using RadDocumentEditor

**RadDocument** has API of its own, but using it has a set of limitations. One of those limitations is that the methods of **RadDocument** are not registered in the undo/redo stack. Thus, once such a method is used, the history stack is cleared and users will no longer be able to undo and redo their previous changes. You can find detailed information on the topic [here](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/features/raddocumenteditor).

## See Also

* [Positioning](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/features/positioning)

* [Selection](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/features/selection)
