Select to view content in your preferred language

Using Inspector to modify an attribute of multiple features but not with the same value

83
1
yesterday
PieterLinks
Occasional Contributor

Hello,

Can I use the Inspector to modify an attribute of multiple features but not with the same value? For me it is not clear in the documentation nor in the samples.

Will this work, or do I have to use another approach?

EditOperation editOperation = new() { Name = editOperationName, ProgressMessage = "Modifying features ...", ShowProgressor = true };
Inspector inspector = new();

using RowCursor cursor = featureClass.Search(new() { WhereClause = "<my whereclause>" });
if (cursor.MoveNext())
{
	Row row = cursor.Current;
	inspector.Load(row);
	inspector["myattribute"] = <any different value>;
}

editOperation.Modify(inspector);
_ = editOperation.Execute();

 

Many thanks,

Pieter

0 Kudos
1 Reply
GKmieliauskas
Esri Regular Contributor

Hi,

Your code will modify only last feature. To modify all features code must look like:

            EditOperation editOperation = new() { Name = editOperationName, ProgressMessage = "Modifying features ...", ShowProgressor = true };
            Inspector inspector = new();

            using (RowCursor cursor = featureClass.Search(new() { WhereClause = "<my whereclause>" }))
            {

                if (cursor.MoveNext())
                {
                    Row row = cursor.Current;
                    inspector.Load(row);
                    inspector["myattribute"] = < any different value>;
                    editOperation.Modify(inspector);
                }
            }

            _ = editOperation.Execute();
0 Kudos