Public Overloads Sub CancelEdit( _ ByVal errorMessage As String, _ Optional ByVal canOverride As Boolean _ )
public void CancelEdit( string errorMessage, bool canOverride )
Parameters
- errorMessage
- canOverride
Public Overloads Sub CancelEdit( _ ByVal errorMessage As String, _ Optional ByVal canOverride As Boolean _ )
public void CancelEdit( string errorMessage, bool canOverride )
// Subscribe to the <see cref="ArcGIS.Desktop.Editing.Events.RowDeletedEvent"/> for the first feature layer's table in the active map. The event handler can be used to intercept and handle row deletion events, such as canceling a delete operation if certain conditions are met. // subscribe to the RowDeletedEvent for the appropriate table // in preparation for the event: public static Guid _currentRowDeletedGuid = Guid.Empty; Table cancelDeleteTable = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault().GetTable(); RowDeletedEvent.Subscribe(rowChangedEventArgs => { // RowEvent callbacks are always called on the QueuedTask so there is no need // to wrap your code within a QueuedTask.Run lambda. var row = rowChangedEventArgs.Row; // check for re-entry if (_currentRowDeletedGuid == rowChangedEventArgs.Guid) return; // cancel the delete if the feature is in Police District 5 var fldIdx = row.FindField("POLICE_DISTRICT"); if (fldIdx != -1) { var value = row[fldIdx].ToString(); if (value == "5") { //cancel with dialog // Note - feature edits on Hosted and Standard Feature Services cannot be cancelled. rowChangedEventArgs.CancelEdit("Delete Event\nAre you sure", true); // or cancel without a dialog // args.CancelEdit(); } } _currentRowDeletedGuid = rowChangedEventArgs.Guid; }, cancelDeleteTable);
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)