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


IMap.DeleteLayer Method (ArcObjects .NET 10.4 SDK)
ArcObjects Library Reference (Carto)  

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

.NET Related Topics

Managing application state