How to stop an edit sesion?

1421
2
Jump to solution
10-21-2014 11:51 AM
Highlighted
New Contributor III

I have coded a Customized Command (or button) in ArcMap by using the ArcObjects library in C#.

I would like to check if there is any ongoing editing session (and close it) when the user presses that button. Is there any way to do that?

Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
New Contributor III

Hi Marcelo,

try this:

public void StopEditing(bool saveChanges)

{

    //Get a reference to the editor.

    UID uid = new UIDClass();

    uid.Value = "esriEditor.Editor";

    IEditor editor = m_application.FindExtensionByCLSID(uid)as IEditor;

   

    //Check to see if a workspace is already being edited.

    if (editor.EditState != esriEditState.esriStateNotEditing)

    {

        editor.StopEditing(saveChanges);

    }

}

have a look at the editing-API: ArcObjects Help for .NET developers

Frank

View solution in original post

Reply
0 Kudos
2 Replies
Highlighted
New Contributor III

Hi Marcelo,

try this:

public void StopEditing(bool saveChanges)

{

    //Get a reference to the editor.

    UID uid = new UIDClass();

    uid.Value = "esriEditor.Editor";

    IEditor editor = m_application.FindExtensionByCLSID(uid)as IEditor;

   

    //Check to see if a workspace is already being edited.

    if (editor.EditState != esriEditState.esriStateNotEditing)

    {

        editor.StopEditing(saveChanges);

    }

}

have a look at the editing-API: ArcObjects Help for .NET developers

Frank

View solution in original post

Reply
0 Kudos
Highlighted
New Contributor III

Thank you Frank!

Just to add that I needed to add the reference ESRI.ArcGIS.Editor and to insert the line

using ESRI.ArcGIS.Editor;

Reply
0 Kudos