This document is archived and information here might be outdated.  Recommended version.


Working with editing events (ArcObjects .NET 10.5 SDK)

Working with editing events


Summary
This topic provides an overview of events in the editor.

In this topic


About edit events

The editor provides a rich set of events for developers to listen and respond to, ensuring that editing customizations remain synchronized with the editor environment and provide a consistent and logical user experience.
Editing events fall into a number of categories. To learn more about how to utilize a given set of events, see the following:

Listening to edit events

To register your customization to listen for editing events, get a reference to the Editor object. Once you have the Editor object, find and declare the appropriate editor event interface that contains the event or events you want to listen for. 
The following code example shows how to register with the editor's OnStartEditing event:
[C#]
private IEditEvents_Event m_editEvents;

//Get the editor.
UID editorUid=new UID();
editorUid.Value="esriEditor.Editor";
m_editor=m_application.FindExtensionByCLSID(editorUid)as IEditor3;
m_editEvents=m_editor as IEditEvents_Event;

m_editEvents.OnStartEditing += new IEditEvents_OnStartEditingEventHandler
    (m_editEvents_OnStartEditing);


void m_editEvents_OnStartEditing()
{
    //Add on start editing code.
}
[VB.NET]
Private m_editEvents As IEditEvents_Event

'Get the editor.
Dim editorUid As New UID()
editorUid.Value="esriEditor.Editor"
m_editor=TryCast(m_application.FindExtensionByCLSID(editorUid), IEditor3)
m_editEvents=TryCast(m_editor, IEditEvents_Event)

AddHandler m_editEvents.OnStartEditing, AddressOf m_editEvents_OnStartEditing

Private Sub m_editEvents_OnStartEditing()
    'Add on start editing code.
End Sub
For more information on how to work with event handlers in ArcGIS, see How to wire ArcObjects .NET events.

Edit tool specific events

To get started, ensure you have an Editor object, which requires that you have the editor namespace (using ESRI.ArcGIS.Editor).
The IEditToolEvents interface adds three more events that you can listen for when working with the editor. These events, which are specific to the edit tool and its interaction in the map, include OnBeginMove, OnFinishMove, and OnMove. The frequency at which these events fire can require the DelayEvents method to be considered.

Understanding event order

Understanding the order and frequency in which events fire can help you define the event that is most appropriate for your code to respond to for a given task. Events that fire frequently should be used sparingly and minimize the complexity of code executed in response to these events.
One way to better understand how edit events are fired is to use the Edit event listener sample, which listens to all the edit events and produces a report that lists the order and frequency of events, when a given operation is performed inside the editor.






To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
Development licensing Deployment licensing
ArcGIS Desktop Standard ArcGIS Desktop Basic
ArcGIS Desktop Advanced ArcGIS Desktop Standard
ArcGIS Desktop Basic ArcGIS Desktop Advanced