Event for switching editing mode

321
5
Jump to solution
12-01-2023 12:24 AM
IgorDrapsin
New Contributor II

Is there any event we can listen for when the edit mode changes?

IgorDrapsin_0-1701420989071.png

 

0 Kudos
1 Solution

Accepted Solutions
sjones_esriau
Esri Contributor

Following on, you can also get a property changed notification on IsEditingEnabled. This should fire with the edit button.

 

    protected override void OnClick()
    {
      Project.Current.PropertyChanged += Current_PropertyChanged;
    }

    private void Current_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
    {
      //if (e.PropertyName == "HasEdits")
      //  MessageBox.Show("HasEdits changed");

      if (e.PropertyName == "IsEditingEnabled")
        MessageBox.Show("IsEditingEnabled changed");
    }

View solution in original post

5 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

Link to editing events in API reference:

ArcGIS.Desktop.Editing.Events Namespace Inheritance Hierarchy

IgorDrapsin
New Contributor II

Hi, 

Thanks for quick answer.

I meant event that is triggered when user interacts with EDIT button.

 

IgorDrapsin_0-1701420680262.png

Main reason for asking it is, we are listening for changes in editing template, but when ESRI switches it, we don't know any more general event to listen to, to detect it.

0 Kudos
GKmieliauskas
Esri Regular Contributor

You can check current status by calling Project.Current.IsEditingEnabled.

If you want enable/disable custom tools depending on editing status, you can use Button/MapTool conditions esri_editing_EditingPossibleCondition, esri_editing_EditingMapCondition  in daml like a single condition or in addition to your conditions.

On Disabling editing EditingCompletedEvent will be raised with Discard argument.

0 Kudos
sjones_esriau
Esri Contributor

Following on, you can also get a property changed notification on IsEditingEnabled. This should fire with the edit button.

 

    protected override void OnClick()
    {
      Project.Current.PropertyChanged += Current_PropertyChanged;
    }

    private void Current_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
    {
      //if (e.PropertyName == "HasEdits")
      //  MessageBox.Show("HasEdits changed");

      if (e.PropertyName == "IsEditingEnabled")
        MessageBox.Show("IsEditingEnabled changed");
    }
IgorDrapsin
New Contributor II

Problem is we use Inspector class to maintain a view of an object, and when "Edit mode" changes, whole inspector nullifies the fields, and this event happens somewhere in the middle of the propagation of this change.

Any idea how to deal with this, or maybe how to formulate the question better?

Ideally when user goes from Edit to Not Edit mode, we would like the fields of inspector to stay as they are and just be read-only not emptied out.

0 Kudos