[GIS] How to show attributes of a new feature in Attribute table area when using IEditor3 and IEditTemplate, ArcGIS 10

arcgis-10.0arcobjectsnet

ArcObjects SDK for .NET and ArcGIS 10 Desktop

Quick snippet to set the stage:

IEditor3 editor.StartOperation();  
IFeature newFeature;
// fill out newFeature.Shape, etc.
newFeature.Store();
editor.StopOperation("Adding new feature");

At this point I'd like to automatically "show" the attributes for this new feature in the Attribute display/table, which could be visible alongside the Create Features template list.

Equivalent process through ArcMap itself:

  • Start the Editor via the Editor Toolbar.
  • Click a feature template from the Create Features list.
  • Click the Attributes button to open the Attributes display.
  • Mouse-down in ArcMap. See new/default attributes for the new feature be displayed in the Attributes table area.

Is the possible with ArcObjects for .NET?

Best Answer

You can execute the command to show the window yourself as in the code below:

    var document = _app.Document;  // _app is an IApplication reference
    var uid = new UIDClass { Value = "esriEditor.AttributionCommand" };
    var item = document.CommandBars.Find(uid, false, false);

    item.Execute();

Edit: then, to view the feature in the Attributes window, you would add it to its layer selection set (via the layer's IFeatureSelection interface). You will also need to notify ArcMap about the selection change - call IFeatureSelection.SelectionChanged, followed by ISelectionEvents.SelectionChanged (you would obtain ISelectionEvents by casting from the Map class).

Related Question