

Public MustInherit NotInheritable Class RowChangedEvent
public static class RowChangedEvent
If you need to edit additional tables within the RowEvent you MUST use the EditOperation that is passed through the RowChangedEventArgs. Do NOT use a new edit operation to create or modify features or rows in your RowEvent callback.
// 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); });
// Attach an event handler to receive notifications when a row in the selected // table is changed. The subscription targets the first <see cref="ArcGIS.Desktop.Mapping.FeatureLayer"/> found in // the active map. Use this method to monitor and respond to edits made to table records within the current map // context. Table thisTable = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault().GetTable(); RowChangedEvent.Subscribe(rowChangedEventArgs => { // set the current row changed guid when you execute the Row.Store method // used for re-entry checking Guid _currentRowChangedGuid = new(); // 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 (only if row.Store is called) if (_currentRowChangedGuid == rowChangedEventArgs.Guid) return; var fldIdx = row.FindField("POLICE_DISTRICT"); if (fldIdx != -1) { //Validate any change to �police district� // cancel the edit if validation on the field fails if (row.HasValueChanged(fldIdx)) { // cancel edit with invalid district (5) var value = row["POLICE_DISTRICT"].ToString(); if (value == "5") { //Cancel edits with invalid �police district� values rowChangedEventArgs.CancelEdit($"Police district {row["POLICE_DISTRICT"]} is invalid"); } } // update the description field row["Description"] = "Row Changed"; // this update with cause another OnRowChanged event to occur // keep track of the row guid to avoid recursion _currentRowChangedGuid = rowChangedEventArgs.Guid; row.Store(); _currentRowChangedGuid = Guid.Empty; } }, thisTable);
// 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);
// Set up a listener for row change events on the table associated with the // provided feature layer. The event subscription occurs within a queued task to ensure thread safety. await QueuedTask.Run(() => { //Listen to the RowChangedEvent that occurs when a Row is changed. var modifiedFeatureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(); ; RowChangedEvent.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 layer's definition var lyrDefn = modifiedFeatureLayer.GetFeatureClass().GetDefinition(); //Get the shape field of the feature class string shapeField = lyrDefn.GetShapeField(); //Index of the shape field var shapeIndex = lyrDefn.FindField(shapeField); //Original geometry of the modified row var geomOrig = rowChangedEventArgs.Row.GetOriginalValue(shapeIndex) as Geometry; //New geometry of the modified row var geomNew = rowChangedEventArgs.Row[shapeIndex] as Geometry; //Compare the two bool shapeChanged = geomOrig.IsEqual(geomNew); if (shapeChanged) { // The geometry has not changed Console.WriteLine("Geometry has not changed"); } else { // The geometry has changed Console.WriteLine("Geometry has changed"); } }, modifiedFeatureLayer.GetTable()); });
System.Object
ArcGIS.Desktop.Editing.Events.RowChangedEvent
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)