4

Currently I'm using this to turn it into a data table

 featureCursor = layer.FeatureClass.Search(que, false);
                    row = featureCursor.NextFeature();

                    if (row != null)
                    {
                        for (int i = 0; i < row.Fields.FieldCount; i++)
                        {
                            dataTable.Columns.Add(row.Fields.get_Field(i).Name);
                        }
                        while (row != null)
                        {
                            dataRow = dataTable.NewRow();

                            for (int j = 0; j < featureCursor.Fields.FieldCount; j++)
                                dataRow[j] = row.get_Value(j);

                            dataTable.Rows.Add(dataRow);
                            row = featureCursor.NextFeature();
                        }
                    }

Does anyone know a more efficient way on doing this.

Also I'm binding the data table to a datagrid, does anyone know a good way I can do this so that I can make the attribute table editable, and values reflected in the feature layer.

I can do this, but not cleanly, has anyone tried this before?

  • Since you are using wpf, are you wanting to leverage INotifyPropertyChanged for the binding? – Kirk Kuykendall Aug 10 '11 at 20:52
3

There is a binding sample from ESRI.

Check it out:

http://edndoc.esri.com/arcobjects/9.2/NET/a6eb84fb-93db-4bc3-82a9-874d8890a8ca.htm

Same sample in ArcGIS 10 documentation

  • Tested this a while back and it worked, I think I also added a wrapper for the IRow to hide the ArcObjects interface from the .net code but that depends on what requirements you have. – MathiasWestin Aug 12 '11 at 7:36
  • 1
    how we could add Sort functionality to this wrapper ? – geogeek Jul 21 '12 at 12:09

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.