2

In the OnChangeFeature event is there a way to determine which field was just edited causing the event to fire? I'm doing several tasks in OnChangeFeature that only need to happen when certain fields are edited, so being able to determine which field just changed would be helpful. Any suggestions?

2
  • 5
    Did you try IRowChanges and loop through each field to see if ValueChanged is true? Jul 8 '11 at 17:39
  • That is the way to go. I was going to answer but Kirk is like Skeet from SO. :P. Jul 8 '11 at 18:13
5

Not sure why everyone is commenting instead of answering but here's an example with both an IRowChanges and an IFeatureChanges (in case you are interested in the geometry). I did have to strip out some lines of code, but this should be close:

IRowChanges: http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#//0025000007vw000000

        IRowChanges rowChanges = obj as IRowChanges;

        for (int i = 0; i < obj.Fields.FieldCount; i++)
        {
                if (rowChanges.ValueChanged[i])
                {
                    object oldValue = rowChanges.get_OriginalValue(i);
                    object newValue = obj.get_Value(i);     


                }
            }
        }

IFeatureChanges: http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#//0025000002qp000000

        IFeatureChanges featureChanges = obj as IFeatureChanges;

        if (featureChanges != null && featureChanges.ShapeChanged)
        {
            // Do something
            // featureChanges.OriginalShape
        }           
2
  • 1
    You can use IRow for the geometry field as well. All you have to do is to pass up the index of the geometry field. Jul 8 '11 at 19:01
  • IRowChanges is exactly what I was looking for. I'd give Kirk answer points as well if I could. Thanks to all.
    – Jeff Berry
    Jul 8 '11 at 20:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.