About the Displaying a TOCControl context menu Sample
[C#]
ZoomToLayer.cs
using ESRI.ArcGIS.ADF.BaseClasses; using ESRI.ArcGIS.Carto; using ESRI.ArcGIS.Controls; namespace ContextMenu { public sealed class ZoomToLayer : BaseCommand { private IMapControl3 m_mapControl; public ZoomToLayer() { base.m_caption = "Zoom To Layer"; } public override void OnClick() { ILayer layer = (ILayer) m_mapControl.CustomProperty; m_mapControl.Extent = layer.AreaOfInterest; } public override void OnCreate(object hook) { m_mapControl = (IMapControl3) hook; } } }
[Visual Basic .NET]
ZoomToLayer.vb
Imports ESRI.ArcGIS.Carto Imports ESRI.ArcGIS.Controls Imports ESRI.ArcGIS.ADF.BaseClasses Public NotInheritable Class ZoomToLayer Inherits BaseCommand Private m_pMapControl As imapcontrol3 Public Sub New() MyBase.New() MyBase.m_caption = "Zoom To Layer" End Sub Public Overrides Sub OnCreate(ByVal hook As Object) m_pMapControl = hook End Sub Public Overrides Sub OnClick() Dim pLayer As ILayer pLayer = m_pMapControl.CustomProperty m_pMapControl.Extent = pLayer.AreaOfInterest End Sub End Class