Accessing a layer's underlying data
The following are the two ways to access the underlying data in a layer.
- The following function returns the FeatureClass via IFeatureLayer:
static IFeatureClass AccessLayersData(ILayer pLayer)
{
IFeatureLayer pFeatureLayer=pLayer as IFeatureLayer;
if (pFeatureLayer != null)
{
return pFeatureLayer.FeatureClass;
}
ArcGIS Desktop
{
return null;
}
}
[VB.NET] Shared Function AccessLayersData(ByVal pLayer As ILayer) As IFeatureClass
Dim pFeatureLayer As IFeatureLayer=pLayer
If Not pFeatureLayer Is Nothing Then
Return pFeatureLayer.FeatureClass
ArcGIS Desktop
Return Nothing
End If
End Function
- The following function returns the DisplayTable by using the IDisplayTable interface:
static ITable AccessLayersDisplayTable(ILayer pLayer)
{
IDisplayTable pDisplayTable=pLayer as IDisplayTable;
if (pDisplayTable != null)
{
return pDisplayTable.DisplayTable;
}
ArcGIS Desktop
{
return null;
}
}
[VB.NET] Shared Function AccessLayersDisplayTable(ByVal pLayer As ILayer) As ITable
Dim pDisplayTable As IDisplayTable=pLayer
If Not pDisplayTable Is Nothing Then
Return pDisplayTable.DisplayTable
ArcGIS Desktop
Return Nothing
End If
End Function
Note that IDisplayTable also includes methods for querying and selecting features. Use these methods to ensure proper behavior when dealing with joined data.
Development licensing | Deployment licensing |
---|---|
ArcGIS for Desktop Basic | ArcGIS for Desktop Basic |
ArcGIS for Desktop Standard | ArcGIS for Desktop Standard |
ArcGIS for Desktop Advanced | ArcGIS for Desktop Advanced |
Engine Developer Kit | Engine |