ArcObjects Library Reference  

RemoveLayer

About the Schematics Engine application Sample

[C#]

RemoveLayer.cs

using ESRI.ArcGIS.ADF.BaseClasses;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Controls;

namespace SchematicApplication
{
	public sealed class RemoveLayer : BaseCommand  
	{
		private IMapControl3 m_mapControl;

		public RemoveLayer()
		{
			base.m_caption = "Remove Layer";
		}
	
		public override void OnClick()
		{
			ILayer layer =  (ILayer) m_mapControl.CustomProperty;
			m_mapControl.Map.DeleteLayer(layer);
		}
	
		public override void OnCreate(object hook)
		{
			m_mapControl = (IMapControl3) hook;
		}

	}
}



[Visual Basic .NET]

RemoveLayer.vb

Imports ESRI.ArcGIS.Carto
Imports ESRI.ArcGIS.Controls
Imports ESRI.ArcGIS.ADF.BaseClasses

Public NotInheritable Class RemoveLayer

    Inherits BaseCommand

    Private m_pMapControl As IMapControl3

    Public Sub New()
        MyBase.New()
        MyBase.m_caption = "Remove Layer"
    End Sub

    Public Overrides Sub OnCreate(ByVal hook As Object)
		m_pMapControl = TryCast(hook, IMapControl3)
    End Sub

    Public Overrides Sub OnClick()
		Dim pLayer As ILayer
		pLayer = TryCast(m_pMapControl.CustomProperty, ILayer)
		m_pMapControl.Map.DeleteLayer(pLayer)
    End Sub
End Class