ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Editing.Events Namespace / RowChangedEventArgs Class / Operation Property
Example

In This Topic
    Operation Property (RowChangedEventArgs)
    In This Topic
    Gets the EditOperation currently being executed. Allows Event handler to make further edits.
    Syntax
    Public ReadOnly Property Operation As EditOperation
    public EditOperation Operation {get;}
    Example
    Create a record in a separate table in the Map within Row Events
    // attach an event handler to receive notifications when a new row is created in the
    // associated table of the first feature layer found in the active map. Use this method to enable custom logic in
    // response to row creation events within your ArcGIS Pro add-in.
    // subscribe to the RowCreatedEvent
    Table table = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault().GetTable();
    RowCreatedEvent.Subscribe(rowChangedEventArgs =>
      {
        // RowEvent callbacks are always called on the QueuedTask so there is no need 
        // to wrap your code within a QueuedTask.Run lambda.
    
        // get the edit operation
        var parentEditOp = rowChangedEventArgs.Operation;
    
        // set up some attributes
        var attribs = new Dictionary<string, object>
        {
          { "Layer", "Parcels" },
          { "Description", "objectId: " + rowChangedEventArgs.Row.GetObjectID().ToString() + " " + DateTime.Now.ToShortTimeString() }
        };
    
        //create a record in an audit table
        var sTable = MapView.Active.Map.FindStandaloneTables("EditHistory")[0];
        var table = sTable.GetTable();
        parentEditOp.Create(table, attribs);
      }, table);
    Create a record in a separate table within Row Events
    // Attach an event handler to the <see cref="ArcGIS.Desktop.Editing.Events.RowCreatedEvent"/> for the table associated with the first <see cref="ArcGIS.Desktop.Mapping.FeatureLayer"/> in the active map. Use this method to monitor when new rows are created
    // in that table, enabling custom logic to be executed in response to record creation events.
    Table firstTable = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault().GetTable();
    RowCreatedEvent.Subscribe(rowChangedEventArgs =>
    {
      // RowEvent callbacks are always called on the QueuedTask so there is no need 
      // to wrap your code within a QueuedTask.Run lambda.
      // update a separate table not in the map when a row is created
      // You MUST use the ArcGIS.Core.Data API to edit the table. Do NOT
      // use a new edit operation in the RowEvent callbacks
      try
      {
        // get the edit operation
        var parentEditOp = rowChangedEventArgs.Operation;
        // set up some attributes
        var attribs = new Dictionary<string, object>
          {
            { "Description", "objectId: " + rowChangedEventArgs.Row.GetObjectID().ToString() + " " + DateTime.Now.ToShortTimeString() }
          };
        // update Notes table with information about the new feature
        using var geoDatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(Project.Current.DefaultGeodatabasePath)));
        using var table = geoDatabase.OpenDataset<Table>("Notes");
        parentEditOp.Create(table, attribs);
      }
      catch (Exception e)
      {
        throw new Exception($@"Error in OnRowCreated for objectId: {rowChangedEventArgs.Row.GetObjectID()} : {e}");
      }
    }, firstTable);
    Modify a record within Row Events - using EditOperation.Modify
    // Subscribe to the <see cref="ArcGIS.Desktop.Editing.Events.RowChangedEvent"/> for
    // the first  <see cref="ArcGIS.Desktop.Mapping.FeatureLayer"/> in the active map. The event handler can be used to
    // respond to changes in rows within the table, such as modifications or updates.
    Table changeTable = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault().GetTable();
    RowChangedEvent.Subscribe(rowChangedEventArgs =>
      {
        // set the last row changed guid when you execute the Row.Store method
        // used for re-entry checking
        Guid _lastEdit = new();
    
        // RowEvent callbacks are always called on the QueuedTask so there is no need 
        // to wrap your code within a QueuedTask.Run lambda.
    
        //example of modifying a field on a row that has been created
        var parentEditOp = rowChangedEventArgs.Operation;
    
        // avoid recursion
        if (_lastEdit != rowChangedEventArgs.Guid)
        {
          //update field on change
          parentEditOp.Modify(rowChangedEventArgs.Row, "ZONING", "New");
    
          _lastEdit = rowChangedEventArgs.Guid;
        }
      }, changeTable);
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also