This documentation is archived and is not being maintained.

UndoEngine Class

Specifies generic undo/redo functionality at design time.


Namespace:  System.ComponentModel.Design
Assembly:  System.Design (in System.Design.dll)

public abstract class UndoEngine : IDisposable

The UndoEngine type exposes the following members.

Protected methodUndoEngineInitializes a new instance of the UndoEngine class.

Public propertyEnabledEnables or disables the UndoEngine.
Public propertyUndoInProgressIndicates if an undo action is in progress.

Protected methodAddUndoUnitAdds an UndoEngine.UndoUnit to the undo stack.
Protected methodCreateUndoUnitCreates a new UndoEngine.UndoUnit.
Protected methodDiscardUndoUnitDiscards an UndoEngine.UndoUnit.
Public methodDispose()Releases all resources used by the UndoEngine.
Protected methodDispose(Boolean)Releases the unmanaged resources used by the UndoEngine and optionally releases the managed resources.
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Protected methodGetRequiredServiceGets the requested service.
Protected methodGetServiceGets the requested service.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodOnUndoingRaises the Undoing event.
Protected methodOnUndoneRaises the Undone event.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

Public eventUndoingOccurs immediately before an undo action is performed.
Public eventUndoneOccurs immediately after an undo action is performed.

The UndoEngine abstract class provides a default implementation of undo functionality at design time. An undo unit represents a single unit of undoable work. This unit is added to a stack and the user can then walk the stack to undo each action. Undo units typically are designed to toggle, which means that calling undo twice returns the application to its starting state.

The UndoEngine class takes advantage of the following characteristics of objects running within the designer:

  • All interesting objects can be persisted to some format by the designer loader.

  • All objects raise property-change notifications when a property is changed.

  • IDesignerHost offers the idea of transactions, which can be used to fabricate an undo action that spans multiple smaller actions.

With these features, UndoEngine can fabricate any undo units it needs automatically.


Do not change property values directly. The UndoEngine class requires you to use the appropriate TypeDescriptor to change property values.

UndoEngine monitors for change notifications to create undo units, and the units themselves consist of serialized object states. The following table shows the services that must be available when UndoEngine is created.




Saves property and object values for a component before and after a change is made.


Notifies the undo engine of changes made to components.


Used to track transactions.


Because the UndoEngine class requires ComponentSerializationService and IComponentChangeService, it is available only at design time.

The undo engine tracks transactions and creates a single undo unit that encompasses a transaction. As a result, the undo engine has control over the duration of an undoable action. Also, because transactions can be named, undoable actions inherit their names from the current transaction. If no transaction is available and a change is reported, the undo engine creates an undo name based on the type of change (for example, "Change property 'Text'").

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.