ArcObjects Library Reference  (Carto)    

esriCarto ILayerEvents Example

[Visual Basic 6.0]
' 1. paste all this code into the ThisDocument module in ArcMap's VBA editor
' 2. run StartListening
' 3. turn layer on/off
' 4. run StopListening to discontinue event listening
Dim WithEvents pLyrEvents As FeatureLayer

Sub StartListening()
  
  Dim pMxDoc As IMxDocument
  Dim pMap As IMap
  Set pMxDoc = Application.Document
  Set pMap = pMxDoc.FocusMap
  Set pLyrEvents = pMap.Layer(0)
End Sub
Private Sub pLyrEvents_VisibilityChanged(ByVal currentState As Boolean)
  Dim pLayer As ILayer
  Set pLayer = pLyrEvents
  MsgBox pLayer.Name & " is visible: " & currentState
End Sub
Sub StopListening()
  Set pLyrEvents = Nothing
End Sub


 


[Visual Basic .NET, C#, C++]
No example is available for Visual Basic .NET, C#, or C++. To view a Visual Basic 6.0 example, click the Language Filter button Language Filter in the upper-left corner of the page.