ArcGIS Pro 3.1 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 EditOperation Operation {get;}
    Public ReadOnly Property Operation As EditOperation
    Example
    Create a record in a separate table in the Map within Row Events
    // Use the EditOperation in the RowChangedEventArgs to append actions to be executed. 
    //  Your actions will become part of the operation and combined into one item on the undo stack
    
    private void HookRowCreatedEvent()
    {
      // subscribe to the RowCreatedEvent
      Table table = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault().GetTable();
      RowCreatedEvent.Subscribe(MyRowCreatedEvent, table);
    }
    
    private void MyRowCreatedEvent(RowChangedEventArgs args)
    {
      // 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 = args.Operation;
    
      // set up some attributes
      var attribs = new Dictionary<string, object> { };
      attribs.Add("Layer", "Parcels");
      attribs.Add("Description", "OID: " + args.Row.GetObjectID().ToString() + " " + DateTime.Now.ToShortTimeString());
    
      //create a record in an audit table
      var sTable = MapView.Active.Map.FindStandaloneTables("EditHistory").First();
      var table = sTable.GetTable();
      parentEditOp.Create(table, attribs);
    }
    Create a record in a separate table within Row Events
    // Use the EditOperation in the RowChangedEventArgs to append actions to be executed. 
    //  Your actions will become part of the operation and combined into one item on the undo stack
    
    private void HookCreatedEvent()
    {
      // subscribe to the RowCreatedEvent
      Table table = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault().GetTable();
      RowCreatedEvent.Subscribe(OnRowCreatedEvent, table);
    }
    
    private void OnRowCreatedEvent(RowChangedEventArgs args)
    {
      // 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 = args.Operation;
    
        // set up some attributes
        var attribs = new Dictionary<string, object> { };
        attribs.Add("Description", "OID: " + args.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)
      {
        MessageBox.Show($@"Error in OnRowCreated for OID: {args.Row.GetObjectID()} : {e.ToString()}");
      }
    }
    Modify a record within Row Events - using EditOperation.Modify
    private void HookChangedEvent()
    {
      // subscribe to the RowChangedEvent
      Table table = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault().GetTable();
      RowChangedEvent.Subscribe(MyRowChangedEvent, table);
    }
    
    private void MyRowChangedEvent(RowChangedEventArgs args)
    {
      // 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 = args.Operation;
    
      // avoid recursion
      if (_lastEdit != args.Guid)
      {
        //update field on change
        parentEditOp.Modify(args.Row, "ZONING", "New");
    
        _lastEdit = args.Guid;
      }
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.0 or higher.
    See Also