ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Core.Data Namespace / Row Class / HasValueChanged Method
The index of the field.
Example

In This Topic
    HasValueChanged Method
    In This Topic
    Gets a value indicating whether the value of the field at the given index has changed. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Function HasValueChanged( _
       ByVal index As Integer _
    ) As Boolean
    public bool HasValueChanged( 
       int index
    )

    Parameters

    index
    The index of the field.

    Return Value

    true if the value has changed; otherwise, false.
    Exceptions
    ExceptionDescription
    A geodatabase-related exception has occurred.
    Example
    Modify a record within Row Events - using Row.Store
    // 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);
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also