form ShowDialog in an editevent

451
5
12-19-2012 11:40 AM
JesseAdams
New Contributor III
Here in my workflow:

1. Click a button on a toolbar - edit session starts
2. Listen for the OnSketchFinished event of the editor
3. Display a data entry dialog for the user to fill in
4. Click the OK button on the dialog to close the form and save edits

The problem I'm running into is I'm unable to use Form.ShowDialog in the OnSketchFinished event and execute stop editing because I'm still inside of the OnSketchFinished event.  It works as expected if I use a non-modal form (Form.Show()) however, ArcMap is still usable, which I don't want.

Any suggestions on how to open a required dialog from the OnSketchFinished event and stop editing when the dialog closes?  Thank you!
0 Kudos
5 Replies
NeilClemmons
Regular Contributor III
I'm pretty sure you can't stop the edit session from within an editor event like this.  A typical workflow would be for the user to start the edit session, sketch a new feature, you listen for the OnCreateFeature event and pop up your dialog which would in turn populate attributes on the new feature and close.  The user would then continue their edit session.  If they save, then your attribute edits would be saved along with the new feature.  If they cancel, then your attribute edits are discarded.  They could also continue creating more features and your dialog would pop up for each.  If want a different workflow, then you may find it easier to skip using the editor altogether and simply write a tool that does what you need it to do.
0 Kudos
JesseAdams
New Contributor III
That makes sense.  I would, however, like to make this as simple as possible for the user.  Seem like there should be a way to "disable" ArcMap while a non-modal form is open?  I would like to cut down the number of times the user needs to click a button.  Thanks.
0 Kudos
KenBuja
MVP Esteemed Contributor
One of my applications uses a modal form for the user to populate the attributes of the feature. I do this in the OnCreateFeature event. However, the OnCreateFeature doesn't get fired when using the Auto-Complete Polygon tool, so in the OnSketchFinished event, I check whether the user is using that tool and use a modal dialog there, also

 Private Sub OnSketchFinished()
    Dim AttribSelForm As New AttributeSelectionForm
    Dim pEditTask As ESRI.ArcGIS.Editor.IEditTask
    Dim pEditTaskSearch As ESRI.ArcGIS.Editor.IEditTaskSearch = My.ArcMap.Editor

    pEditTask = pEditTaskSearch.TaskByUniqueName("TitusUI_AutoCompletePolygonTask")
    If My.ArcMap.Editor.CurrentTask Is pEditTask Then
        AttribSelForm.ShowDialog(System.Windows.Forms.Control.FromHandle(My.ArcMap.Application.hWnd))
0 Kudos
LeoDonahue
Occasional Contributor III
What about this?

In the What's new section for ArcObjects 10.1 docs:


geodatabase
       The following enhancements have been made to the com.esri.arcgis.geodatabase package:
      

  • The workspace editing event model has been extended  to include the IWorkspaceEditEvents2 interface. This interface exposes  an event method, onBeginStopEditing(), that is triggered when client  code calls the stopEditing() method on the IWorkspaceEdit interface and  allows custom behavior to occur before the edit session has stopped.  This is in contrast to the onStopEditing() method on the  IWorkspaceEditEvents interface that is triggered after the edit session  has already been stopped.


0 Kudos
JesseAdams
New Contributor III
Thanks for the suggestion.  Unfortunately I would still need to call StopEditing in the OnSketchComplete event.  Looks like the only way is through a custom tool or non-modal form.  Strange how this workflow doesn't have an issue on polygon feature classes but does on point feature classes?  Very inconsistent.
0 Kudos