Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

share|improve this question
4  
Did you try IRowChanges and loop through each field to see if ValueChanged is true? –  Kirk Kuykendall 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. –  George Jul 8 '11 at 18:13
add comment

1 Answer 1

up vote 4 down vote accepted

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
        }           
share|improve this answer
    
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. –  George Jul 8 '11 at 19:01
    
+1 this looks good. –  Kirk Kuykendall Jul 8 '11 at 19:32
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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