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
You can enable or disable the history for the RadDocument via the Enabled property of the DocumentHistory.
this.radRichTextEditor1.Document.History.IsEnabled = false;
Me.radRichTextEditor1.Document.History.IsEnabled = False
Clear History
To clear the history you just have to call the Clear() method of the DocumentHistory class.
this.radRichTextEditor1.Document.History.Clear();
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.
private void UndoAction()
{
this.radRichTextEditor1.Undo();
}
private void RedoAction()
{
this.radRichTextEditor1.Redo();
}
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.
this.radRichTextEditor1.Document.History.Depth = 500;
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.