This document is archived and information here might be outdated. Recommended version. |
Get the FeatureLayer by specifying the Layer Index Number.
///<summary>Get the FeatureLayer by specifying the Layer Index Number.</summary> /// ///<param name="activeView">An IActiveView interface</param> ///<param name="layerIndex">An System.Int32 that is the layer index number in the map (zero based). Example: 3</param> /// ///<returns>An IFeatureLayer interface (if found) or Nothing (if not found)</returns> /// ///<remarks></remarks> public ESRI.ArcGIS.Carto.IFeatureLayer GetFeatureLayerFromLayerIndexNumber(ESRI.ArcGIS.Carto.IActiveView activeView, System.Int32 layerIndex) { if (activeView == null || layerIndex < 0) { return null; } ESRI.ArcGIS.Carto.IMap map=activeView.FocusMap; if (layerIndex < map.LayerCount && map.get_Layer(layerIndex) is ESRI.ArcGIS.Carto.IFeatureLayer) { return (ESRI.ArcGIS.Carto.IFeatureLayer)activeView.FocusMap.get_Layer(layerIndex); // Explicit Cast } else { return null; } }
'''<summary>Get the FeatureLayer by specifying the Layer Index Number.</summary> ''' '''<param name="activeView">An IActiveView interface</param> '''<param name="layerIndex">An System.Int32 that is the layer index number in the map (zero based). Example: 3</param> ''' '''<returns>An IFeatureLayer interface (if found) or Nothing (if not found)</returns> ''' '''<remarks></remarks> Public Function GetFeatureLayerFromLayerIndexNumber(ByVal activeView As ESRI.ArcGIS.Carto.IActiveView, ByVal layerIndex As System.Int32) As ESRI.ArcGIS.Carto.IFeatureLayer If activeView Is Nothing OrElse layerIndex < 0 Then Return Nothing End If Dim map As ESRI.ArcGIS.Carto.IMap=activeView.FocusMap If layerIndex < map.LayerCount AndAlso TypeOf map.Layer(layerIndex) Is ESRI.ArcGIS.Carto.IFeatureLayer Then Return CType(activeView.FocusMap.Layer(layerIndex), ESRI.ArcGIS.Carto.IFeatureLayer) ' Explicit Cast Else Return Nothing End If End Function