Editing in a custom application


Purpose This sample demonstrates how to hide the complexity of editing in an ArcGIS Engine application by presenting a simple editing interface to users. It also shows how to impose business rules on the editing process by listening to ArcGIS Engine edit events. Applications that allow users to edit data often attempt to simplify the editing process and maintain data integrity through business rules. This sample demonstrates how to achieve this in an ArcGIS Engine application in the following ways:

Presenting a simple user interface (UI) for editing. Users can only edit the Highways layer and do not have to understand what a target layer is or how to select an appropriate edit task.
Using out-of-the-box tools and edit tasks. User can create highways and modify (move, insert, and delete vertices) and reshape the highways.
Imposing business rules on the editing process. For demonstration purposes, a hypothetical rule has been created that states that highways cannot intersect lakes.


The application listens to the IEngineEditEvents.OnSketchModified event to check whether an edit is valid. A spatial query is performed in the IsHighwaysEditValid function to determine whether the highway feature being edited intersects the Lakes layer. If the function returns false, the edit is rolled back by calling the IOperationStack.Undo method. The user is notified with an Invalid Edit warning.


How to use

See How to use ArcGIS samples for help running the sample.

  1. Start the sample application. The ushigh.shp shapefile from the sample data is loaded into the Map control.
  2. Click the Start button to start an edit session. The Create, Modify, and Reshape buttons are enabled, and the Start button is replaced by the Finish button.
  3. Click the Create button to create a new feature. The Sketch tool is activated.
  4. Sketch a highway feature on the map. If the feature crosses a lake, you are notified that the edit is invalid.
  5. Double-click to finish the sketch.
  6. Click the Modify button to modify a feature. The Edit tool is activated. If you have a highway feature selected, the Insert and Delete Vertex commands are also enabled.
  7. Use the Edit tool to select a highway feature to edit. The feature's vertices are displayed.
  8. Zoom in on the feature, and use the Insert or Delete commands on any of the feature's vertices. You are notified if your modifications cause a highway feature to cross a lake.
  9. Click the Reshape button to reshape a highway feature. The Edit tool is activated. If you have a highway feature selected, the Sketch tool is also enabled.
  10. Use the Edit tool to select a highway feature to edit. The Sketch tool is now enabled if it wasn't in the previous step.
  11. Use the Sketch tool to digitize a line that crosses the selected highway feature in at least two places. You are notified if your modifications cause a highway feature to cross a lake.
  12. Click Finish to stop the editing and save your edits if desired.





Development licensing Deployment licensing
Engine Developer Kit Engine Runtime
ArcView