This document is archived and information here might be outdated.  Recommended version.

IMap.DeleteLayer Method (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > ArcObjects namespaces > Carto > ESRI.ArcGIS.Carto > Interfaces > IM > IMap Interface > IMap.DeleteLayer Method
ArcGIS Developer Help

IMap.DeleteLayer Method

Deletes a layer from the map.

[Visual Basic .NET]
Public Sub DeleteLayer ( _
    ByVal Layer As ILayer _
public void DeleteLayer (
    ILayer Layer
HRESULT DeleteLayer(
  ILayer* Layer
Layer [in]

Layer is a parameter of type ILayer*

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.


DeleteLayer will automatically recalculate the Map's extent after the successful deletion of a layer.
If a layer is selected in the TOC window (IMxDocument::SelectedLayer), you can pass this to DeleteLayer.
When deleting a layer that references a feature class, like a FeatureLayer, executing IDataLayer2::Disconnect will ensure that references to the feature class are cleared.

See Also

IMap Interface