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


Responding to changes in the edit session (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > Developing with ArcGIS > Learning ArcObjects > Editing data > ArcGIS for Desktop editing for developers > Working with editing events > Responding to changes in the edit session

Responding to changes in the edit session


Summary
This topic describes the events the editor provides that allow developers to listen and respond to changes in the edit session state.

In this topic


About responding to changes in the edit session

Some of the most common events that developers working with the editor use is those that are triggered when the state of an edit session changes. The editor has the following events that provide information about these changes:
As a developer, there are several instances where listening to these changes is essential. 
Most customizations, including but not limited to tools, commands, and edit extensions listen for these events. Tools and commands often control their enabled state based on these events. Edit extensions listen so they can discard any state information about the workspace or its objects since this is not safe to maintain across edit session boundaries.
When listening to these events, it is important that no attempts are made to change the edit session state inside these handlers. Because there might be several customizations listening to the same event, the state must remain static to allow each client listening to these events to process it completely before the edit session state is changed.

Starting an edit session using the geodatabase API

In most cases, editor customizations are used in conjunction with the core editor user interface (UI). In these situations, the edit session is generally controlled through the commands on the Editor menu. These commands utilize the editor's methods to manage an edit session - IEditor.StartEditing, IEditor.StopEditing, and IEditor.SaveEdits. By using these methods, editor customizations are assured of being notified of any changes to the edit session state. 
Do not use geodatabase methods to manage the edit session in conjunction with the editor. In these instances, many editor UI components rely on logic that is only executed if the editor's session management methods are used. 
For more information on managing edit sessions and the differences between the editor and geodatabase, see Managing edit sessions and edit operations.
The following code example shows how to listen for the editor's OnStartEditing event:
[C#]
//Declare the editor and the edit events interface.
private IEditor m_editor;
private IEditEvents_Event m_editEvents;

public void Startup(ref object initializationData)
{
    if (initializationData != null && initializationData is IEditor)
    {

        m_editor=(IEditor)initializationData;
    }

    //Cast the events interface to the editor.
    m_editEvents=(IEditEvents_Event)m_editor;

    //Wire edit events OnStartEditing.
    m_editEvents.OnStartEditing += new IEditEvents_OnStartEditing
        (m_editEvents_OnStartEditing);
}
[VB.NET]
'Declare the editor and the edit event interface.
Private m_editor As IEditor
Private m_editEvents As IEditEvents_Event

'Use the extension to get the editor.

Public Sub Startup(ByRef initializationData As Object) Implements IExtension.Startup
    If Not initializationData Is Nothing AndAlso TypeOf initializationData Is IEditor Then
        m_editor=CType(initializationData, IEditor)
        
        'Cast the editor to the edit events interface.
        m_editEvents=CType(m_editor, IEditEvents_Event)
        
        'Wire editor events.
        AddHandler m_editEvents.OnStartEditing, AddressOf m_editEvents_OnStartEditing
    End If
End Sub






Development licensing Deployment licensing
ArcGIS Desktop Advanced ArcGIS Desktop Advanced
ArcGIS Desktop Standard ArcGIS Desktop Standard
ArcGIS Desktop Basic ArcGIS Desktop Basic