AnsweredAssumed Answered

ArcMap TOC Selection Changed Event help

Question asked by clint.dow on Jul 9, 2014
Latest reply on Jul 10, 2014 by clint.dow

I have been trying to figure this out for almost a full working day and I just can't get it working. All I want to do is fire an event when the user clicks different layers in the arcmap table of contents.



I can get it working with, for example, the PageLayout using this:



IActiveViewEvents_Event pageLayoutEvent = ArcMap.Document.PageLayout as IActiveViewEvents_Event;



I have googled and looked into a bunch of different threads, all revolving around the concept of 'IActiveViewEvents_Event' interfaces. Perhaps this is the wrong event interface for what I am trying to do. I've been able to get the event when the selection changes within the map document itself.. But I simply cant get an event to fire in the Table of Contents.



My best attempt looks like this:


IActiveViewEvents toc = ArcMap.Document.get_ContentsView(0) as IActiveViewEvents;

IActiveViewEvents_Event tocEvent = ((TOCCatalogView)toc).SelectedItem as IActiveViewEvents_Event;



However tocEvent is set to null. If I do not cast to IActiveViewEvents_Event, SelectedItem is not null...



If anyone could provide a full example of doing this I would be very grateful!