Bagikan melalui


Document Data and Document View in Custom Editors

Note

This article applies to Visual Studio 2015. 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

A custom editor consists of two parts: a document data object and a document view object. As the names suggest, the document data object represents the text data to be displayed, and the document view object (or "view") represents one or more windows in which to display the document data object.

Document Data Object

A document data object is a data representation of text in the text buffer. It is a COM object that stores document text and other information, handles document persistence, and enables multiple views of its data. For more information, see

DocumentData[] and Document Windows.

Custom editors and designers can opt to use the VsTextBuffer object or their own custom buffer. VsTextBuffer follows the simplified embedding model for a standard editor, supports multiple views, and provides event interfaces that are used to manage multiple views.

Document View Object

A window that displays code and other text is known as a document view or view. When you create an editor, you can choose either a single view, in which text is displayed in a single window, or a multiple view, in which text is displayed in more than one window. Your choice depends on your application. For example, if you need side-by-side editing, you would choose multiple view. Each view is associated with an entry in the integrated development environment's (IDE) running document table (RDT). View windows belong to a project or an IVsHierarchy object.

If your editor supports multiple views of a document data object, then your document data and document view objects must be separate. Otherwise, they can be grouped together. For more information, see Supporting Multiple Document Views.

The IDE notifies views about events (for example, when a solution containing a document is closed) by matching an item identifier (ItemID) for each entry in the running document table. For more information on this, see Running Document Table.

There are two options for creating a view for a custom editor. One is the in-place activation model, where the view is hosted in a window using either an ActiveX control or a document data object. The second is the simplified embedding model, where the view is hosted by Visual Studio and IVsWindowPane is implemented to handle window commands. For information about the in-place activation model, see In-Place Activation. For information about the simplified embedding model, see Simplified Embedding.

See Also

Supporting Multiple Document Views
Simplified Embedding
How to: Attach Views to Document Data
Document Lock Holder Management
Single and Multi-tab Views
Saving a Standard Document
Persistence and the Running Document Table
Determining Which Editor Opens a File in a Project
Editor Factories