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 _
)
[C#]
public void DeleteLayer (
    ILayer Layer
);
[C++]
HRESULT DeleteLayer(
  ILayer* Layer
);
[C++]
Parameters
Layer [in]

Layer is a parameter of type ILayer*

Product Availability

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

Remarks

DeleteLayer will automatically recalculate the Map's extent after the successful deletion of a layer.
Tips:
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