How to stop an edit sesion?

1717
2
Jump to solution
10-21-2014 11:51 AM
MarceloLago
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?

0 Kudos
1 Solution

Accepted Solutions
FrankHellwich1
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

0 Kudos
2 Replies
FrankHellwich1
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

0 Kudos
MarceloLago
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;

0 Kudos