Code for getting hold of a table, using a layer's name
Details
This just shows how to loop through the layers in the FocusMap until you find the right one, and get the table out of it.
Original author/s: Andy Evans
Original location/s:
Adapted by:
License: none
Imports and instance variables
import com.esri.arcgis.framework.*; import com.esri.arcgis.arcmapui.*; import com.esri.arcgis.carto.*; import com.esri.arcgis.geodatabase.*; private IApplication app = someApplication; // Set up by an init() or equivalent.
Code
IMxDocument mxDocument = (IMxDocument)app.getDocument(); IMap map = mxDocument.getFocusMap(); ILayer layer = null; for (int i=0; i < map.getLayerCount(); i++) { layer = map.getLayer(i); if (layer.getName().equals("layerName")) { break; } } IAttributeTable pAttributeTable = (IAttributeTable) layer; ITable table = pAttributeTable.getAttributeTable();