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

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

Parameters 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

.NET Related Topics

Managing application state