You are here: > ESRI Forums > arcgis desktop discussion forums > Thread Replies

ArcGIS Desktop Discussion Forums

ArcGIS Desktop - ArcObjects General forum

Layers visibility on/off event in .Net   Amy GIS Jun 08, 2007
Re: Layers visibility on/off event in .Net   Amit Nalla Jun 08, 2007
Re: Layers visibility on/off event in .Net   Amy GIS Jun 08, 2007
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Layers visibility on/off event in .Net 
Author Amy GIS 
Date Jun 08, 2007 
Message Does anybody know how to listen to arcmap layers's visible(on/off) check box (in TOC) event in vb.net?

I have the following code which is not working. Not sure if it is correct?

Please help me.

Thanks,
Amy
 
 
Private pLyrEvents As ILayerEvents_VisibilityChangedEventHandler
pLyrEvents = New ILayerEvents_VisibilityChangedEventHandler(AddressOf pLyrEvents_VisibilityChanged)
pLyrEvents = m_map.Layer(0)
AddHandler CType(m_map, ILayerEvents_Event).VisibilityChanged, pLyrEvents
 
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Layers visibility on/off event in .Net 
Author Amit Nalla 
Date Jun 08, 2007 
Message This is how I'd do it in C#. I guess, you can figure it out in VB or just use one of the free online code converters. 
 
private ILayerEvents_Event pLayerEvents;
        void mActiveViewEvents_ItemAdded(object Item)
        {
            if (Item is IFeatureLayer)
            {
                pLayerEvents = Item as ILayerEvents_Event;
                pLayerEvents.VisibilityChanged += new ILayerEvents_VisibilityChangedEventHandler(pLayerEvents_VisibilityChanged);
            }
        }

        void pLayerEvents_VisibilityChanged(bool currentState)
        {
            //do something here
        }
 
  Amit.

Amit R. Nalla
Senior Software Engineer
GeoFields, Inc
Atlanta, GA. 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Layers visibility on/off event in .Net 
Author Amy GIS 
Date Jun 08, 2007 
Message It did work.
Thank you very much.

Amy