If Edit Session On Then...

729
3
Jump to solution
06-28-2012 10:06 AM
DaveCouture
New Contributor III
How can I check if the Edit Session is on?  With my current code, ArcMap crashes when not in Edit Session.  I'd like to put a warning for the user to start an Edit Session, if they forgot.

                 Dim pEnumFeature As ESRI.ArcGIS.Geodatabase.IEnumFeature         Dim pFeature As ESRI.ArcGIS.Geodatabase.IFeature         Dim pEditor As ESRI.ArcGIS.Editor.IEditor         Dim featureCode As String         Dim def As String          pEditor = My.ArcMap.Application.FindExtensionByName("esriEditor.Editor")         pEnumFeature = pEditor.EditSelection         pEnumFeature.Reset()         pFeature = pEnumFeature.Next         pEditor.StartOperation()
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor
You can check the edit state by using IEditor::Editstate. An example to check whether an edit session has been started on the selected map:

If My.ArcMap.Editor.EditState <> ESRI.ArcGIS.Editor.esriEditState.esriStateEditing then


As for ArcMap crashing, do you use Try..Catch exception handling?

View solution in original post

0 Kudos
3 Replies
ThavitinaiduGulivindala
Occasional Contributor
Use IEditor.EditState property 🙂
0 Kudos
NeilClemmons
Regular Contributor III
Do you have error handling in your code?  I don't see it in what you've posted.  It's up to you as the developer to handle errors within your own code (that's not something that ArcMap could do for you).  All of your code should be within Try/Catch blocks at points where exceptions would be thrown out to the ArcMap application.  You should also place Try/Catch blocks within your call stack at points where it makes sense (where those points are is up to you).  In the code you've posted, you're starting an edit operation without first starting an edit session.  This isn't allowed.  You must first called IEditor.StartEditing and pass in a reference to the workspace you want to edit.  You can also preface that by checking IEditor.EditState to see if an edit session has already been started and then check IEditor.EditWorkspace to see if the edit session has been started on the workspace you want to edit.  If the edit session has not been started, then you will need to start it yourself.  If it has been started but on a different workspace then you should stop the current edit session and start a new one.
0 Kudos
KenBuja
MVP Esteemed Contributor
You can check the edit state by using IEditor::Editstate. An example to check whether an edit session has been started on the selected map:

If My.ArcMap.Editor.EditState <> ESRI.ArcGIS.Editor.esriEditState.esriStateEditing then


As for ArcMap crashing, do you use Try..Catch exception handling?
0 Kudos