ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Editing.Events Namespace / RowDeletedEvent Class
Members Example

In This Topic
    RowDeletedEvent Class
    In This Topic
    Occurs when a Row is deleted.
    Object Model
    RowDeletedEvent ClassSubscriptionToken Class
    Syntax
    Public MustInherit NotInheritable Class RowDeletedEvent 
    public static class RowDeletedEvent 
    Remarks
    The RowDeletedEvent is published during the execution of the edit operation. Any modifications performed within the RowEvent handler can cause cascaded events to be generated. Make sure you have an exit condition to avoid infinite recursion. For example, if you are changing a feature attribute within a RowCreatedEvent or RowChangedEvent, consider tracking that feature's objectID to ignore the corresponding RowChangedEvent your attribute change will generate.

    If you need to edit additional tables within the RowEvent you MUST use the ArcGIS.Core.Data API to edit the tables directly. Do NOT use a new edit operation to create or modify features or rows in your RowEvent callback.

    Example
    Subscribe to Row Events
    // Subscribes to row events for the currently selected feature layer in the active map view.
    await QueuedTask.Run(() =>
    {
      //Listen for row events on a layer
      var featLayer = MapView.Active.GetSelectedLayers()[0] as FeatureLayer;
      var layerTable = featLayer.GetTable();
    
      //subscribe to row events
      // row created event
      var rowCreateToken = RowCreatedEvent.Subscribe(rowChangedEventArgs => { }, layerTable);
      // row changed event
      var rowChangeToken = RowChangedEvent.Subscribe(rowChangedEventArgs => { }, layerTable);
      // row deleted event
      var rowDeleteToken = RowDeletedEvent.Subscribe(rowChangedEventArgs => { }, layerTable);
    });
    Cancel a delete
    // 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);
    Inheritance Hierarchy

    System.Object
       ArcGIS.Desktop.Editing.Events.RowDeletedEvent

    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also