As a developer I can use ArcPy (Python) or ArcObjects (.NET) to develop some extensions or tools for ArcGIS platform. But I need to handle some events. When a user connected to an Enterprise geodatabase and create an object in database table, can I handle the events of CREATE, UPDATE or DELETE? Is this possible?

  • 3
    INSERT, UPDATE, and DELETE are database events, not application events. Furthermore, in a versioned geodatabase, they are all modeled as INSERTs. The only way for an application to perceive database events is to control how they are requested. – Vince Jun 10 '19 at 14:15
  • 1
    If you're still looking for an answer to this question you can determine if the IEditor.EditWorkspace.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace in the OnStartEditing event then wire the events for OnCreateFeature, OnChangeFeature and OnDeleteFeature from IEditEvents resources.arcgis.com/en/help/arcobjects-net/componenthelp/… which are the corresponding events in ArcMap. I should have some working C# or VB.net code if you're interested. I would have responded earlier but I was in hospital around the time you asked this question. – Michael Stimson Jun 18 '19 at 4:53
  • Thanks @MichaelStimson, I am still looking for an answer, yes. Should I create an extension for your solution? If you have some code can you share as an asnwer? – barteloma Jun 24 '19 at 6:46

This is from working code, in this example 'timer save' a window pops up when a time has elapsed reminding the user to save, so I only use OnStartEditing and OnStopEditing events; It is important to note that this occurs in the form load event as there is an attached form:

private void TimerSaveForm_Load(object sender, EventArgs e)
    vSaveEditsWarn = DateTime.Now;
    this.FormClosing += new FormClosingEventHandler(TimerSaveForm_FormClosing); // to cleanup events
    IEditor pED = pApplication.FindExtensionByName("ESRI Object Editor") as IEditor;

    ((IEditEvents_Event)pED).OnStartEditing += new IEditEvents_OnStartEditingEventHandler(TimerSaveForm_OnStartEditing);
    ((IEditEvents_Event)pED).OnStopEditing += new IEditEvents_OnStopEditingEventHandler(TimerSaveForm_OnStopEditing);
    TimerSaveForm.CheckForIllegalCrossThreadCalls = false;
    this.TopMost = true; // ensure this form isn't lost under another window'

void TimerSaveForm_OnStopEditing(bool save)
    vTimer.Stop(); // System.Timers.Timer object
    StartStopButton.Text = "Start";
    this.BackColor = System.Drawing.SystemColors.Control;
    this.Text = "Auto SaveEdits";

void TimerSaveForm_OnStartEditing()
    vTimer.Start(); // System.Timers.Timer object
    StartStopButton.Text = "Stop";
    this.BackColor = System.Drawing.SystemColors.Control;

If you're writing a tool without a form you can wire it from the tool directly in the initializer. From the sounds of it you want to capture the On Start/Stop to grab your edit workspace then potentially OnCreateFeature, OnChangeFeature and OnDeleteFeature, which are wired in the same manner as the code shown.

When you start typing the event intelisense should finish the rest for you and offer to create the function wired to the event, I advise you to say yes and yes, not because I'm lazy but it saves mistyping and ensures that the event is correctly associated with the function.. if you try to create the function first Visual Studio may not recognize the association which will lead to hours of frustration trying to work out why an event isn't firing even though everything is spelled correctly.

Unwiring the events is a little counter intuitive, it's almost identical to the wiring but use -= instead of +=:

((IEditEvents_Event)pED).OnStartEditing -= new IEditEvents_OnStartEditingEventHandler(TimerSaveForm_OnStartEditing);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.