ArcObjects Library Reference  (Editor)    

Editor Class

The Object Editor Extension.

Editor is a non-creatable object. References to non-creatable objects must be obtained through other objects.

Product Availability

Available with ArcGIS Desktop.

Supported Platforms

Windows

Extended Error Information

Use the ISupportErrorInfo method InterfaceSupportsErrorInfo to determine if the object supports extended error information. If the object supports extended error info, VC++ developers should use the OLE/COM IErrorInfo interface to access the ErrorInfo object. Visual Basic developers should use the global error object Err to retrieve this extended error information.

Interfaces

Interfaces Description
IActiveViewEvents (esriCarto) Provides access to events that occur when the state of the active view changes.
IAttributeTransferType Provides access to members that control the behavior of the attribute transfer interfaces.
IEditAnnotationProperties Provides access to members that control the annotation properties of an edit session.
IEditAttributeProperties Provides access to members that control the short transaction attribute properties of an edit session.
IEditLayers Provides access to members that control information about layers in the edit session.
IEditor Provides access to members that control the behavior of the editor.
IEditor2 Provides access to methods that extend the IEditor interface. The additional members control the behavior of the auxiliary selection anchor.
IEditorZ Provides access to members that access and manipulate the z-environment of the editor.
IEditProperties Provides access to members that control the properties of an edit session.
IEditProperties2 Provides access to more members that control the properties of an edit session.
IEditProperties3 Provides access to more members that control the properties of an edit session.
IEditSketch Provides access to members that access and manipulate the edit sketch.
IEditSketch2 Provides access to members that access and manipulate the edit sketch.
IEditTaskSearch Provides access to members that find edit tasks by name.
IExtension (esriSystem) Provides access to members that define an extension.
IExtensionAccelerators (esriSystem) Provides access to a method that creates extension accelerators.
IExtensionManager (esriSystem) Provides access to members that query extension.
IPersist Defines the single method GetClassID, which is designed to supply the CLSID of an object that can be stored persistently in the system. IPersist is the base interface for three other interfaces: IPersistStorage, IPersistStream, and IPersistFile.
IPersistStream (esriSystem)
ISnapEnvironment Provides access to members that manage the snap agents used by the editor.
ISnapEnvironment2 Provides access to members used to manipulate the snap environment for Zs.
ISupportErrorInfo Indicates whether a specific interface can return Automation error objects.

Event Interfaces

Interfaces Description
IEditEvents (default) Provides access to editor events. Implement it to listen for specific events that occur during an edit session.
IEditEvents2 Provides access to more editor events. Implement it to listen for specific events that occur during an edit session.
IEditEvents3 Provides access to more editor events. Implement it to listen for specific events that occur during an edit session.
IEditEvents4 Provides access to more editor events. Implement it to listen for specific events that occur during an edit session.

Remarks

The Editor object represents the Editor extension to ArcMap - it is the main editing component and the focal point for all other objects in the Editor object model.  Although the Editor object is not cocreateable, the Editor object is automatically created whenever a new ArcMap session starts; in fact, all ArcMap extension objects are automatically instantiated when ArcMap is first started.
 
The Editor object is used to provide a common editing environment for features stored in the ESRI vector geographic datasets: geodatabases, coverages, and shapefiles.  Use the Editor object to: create edit operations, create and manage an edit sketch, set the current task, set the target layer, establish a snapping environment, and respond to editor events.
 
To get a reference to the Editor extension, use IApplication::FindExtensionByCLSID or IApplication::FindExtensionByName
The Editor manages a collection of related objects including snap agents, edit tasks, and editor extension. References to these objects are provided by the various Editor members. For example, IEditor::Task provides a reference to a specific task given a index.
[C#]

private IEditor m_editor;
private IApplication m_application;

// Would get the app by using hook during implementation of CreateCommand
      ...
      UID editorUid = new UID();
      editorUid.Value = "esriEditor.Editor";
      if (app == null)
        return;
     
      m_editor = app.FindExtensionByCLSID(editorUid) as IEditor;

//To use the Editor name instead of UID
     ....
       if (app == null)
        return;

       m_editor = app.FindExtensionByName("ESRI Object Editor") as IEditor;

[Visual Basic 6.0]

The following VBA code examples shows both methods being used to acquire a reference of type IEditor to the Editor object.

 Sub GetEditorExtensionByCLSID()
   Dim pEditor As IEditor
   Dim pID As New UID
   pID = "esriEditor.Editor"
   Set pEditor = Application.FindExtensionByCLSID(pID)
 End Sub
 
 Sub GetEditorExtensionByName()
   Dim pEditor as IEditor
   Set pEditor = Application.FindExtensionByName("ESRI Object Editor")
 End Sub
[Visual Basic .NET]

In VB.Net you would get the reference to IApplication from hook in the ICommand::OnCreate() hook parameter

Private m_editor As IEditor
Private m_application As IApplication
...
Public Overrides Sub OnCreate(ByVal hook As Object)
    If Not (hook Is Nothing) Then
      If TypeOf (hook) Is IApplication Then
        m_application = CType(hook, IApplication)
      End If
    Else
      Exit Sub
    End If
    Dim editorUid As New UID
    m_application = hook
    editorUid.Value = "esriEditor.Editor"
    m_editor = m_application.FindExtensionByCLSID(editorUid)
  End Sub
'Or it can be found by name. 
...
  ...
  m_editor = m_application.FindExtensionByName("ESRI Object Editor")
End Sub

Working with Events

[Visual Basic 6.0]

When working with Editor's default outbound interface in Visual Basic 6 declare variables as follows:

Private WithEvents pEditor as Editor

When implementing IEditEvents2 declare variables as follows:

Private WithEvents pEditEvents2 as EditEvents2

When implementing IEditEvents3 declare variables as follows:

Private WithEvents pEditEvents3 as EditEvents3

When implementing IEditEvents4 declare variables as follows:

Private WithEvents pEditEvents4 as EditEvents4

See Also

IWorkspaceEditEvents Interface | IWorkspaceEdit Interface | ISpatialCacheManager Interface | IFeatureClass.CreateFeature Method | Editor Class

Example

Editor_Example