Jaa


Supply undo support to designers

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

Designers, like editors, typically need to support undo operations so that users can reverse their recent changes when modifying a code element.

Most designers implemented in Visual Studio have "undo" support automatically provided by the environment.

Designer implementations that need to provide support for the undo feature:

For more information on writing designers using .NET Framework, see Extend Design-Time Support.

The Visual Studio SDK provides a default undo infrastructure by:

Obtain Undo Support Automatically

Any designer created in Visual Studio has automatic and full undo support if, the designer:

  • Makes use of a Control based class for its user interface.

  • Employs standard CodeDOM-based code generation and parsing system for code generation and persistence.

    For more information about working with Visual Studio CodeDOM support, see Dynamic Source Code Generation and Compilation.

When to Use Explicit Designer Undo Support

Designers must supply their own undo management if they use a graphical user interface, referred to as a view adapter, other than the one supplied by Control.

An example of this might be creating a product with a web-based graphical design interface rather than a .NET Framework-based graphical interface.

In such cases, one would need to register this view adapter with Visual Studio using ProvideViewAdapterAttribute, and provide explicit undo management.

Designers need to provide CodeDOM and persistence support if they do not use the Visual Studio code generation model provided in the System.CodeDom name space.

Undo Support Features of the Designer

The Environment SDK provides default implementations of interfaces needed to provide undo support that can be used by designers not using Control based classes for their user interfaces or the standard CodeDOM and persistence model.

The OleUndoEngine class derives from the .NET Framework UndoEngine class using an implementation of the IOleUndoManager class to manage undo operations.

Visual Studio provides the following feature to designer undo:

The Environment SDK provides CodeDOM and persistence support by supplying:

Use the Environment SDK Features to Supply Undo Support

To obtain undo support, an object implementing a designer must instantiate and initialize an instance of the OleUndoEngine class with a valid IServiceProvider implementation. This IServiceProvider class must provide the following services:

Designers implementing a OleUndoEngine based undo mechanism automatically tracks changes if:

See also