ArcMap TOC Selection Changed Event help

2539
1
Jump to solution
07-09-2014 11:07 AM
ClintDow
Occasional Contributor

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!

0 Kudos
1 Solution

Accepted Solutions
ClintDow
Occasional Contributor

I got an answer to this over at StackExchange, basically the event isn't implemented for the TOC. There's a couple 'hack' workarounds to get more or less the same functionality, but in my case I have used this information to explain to my team lead why adding a button and click event will be more suitable to our needs.

View solution in original post

0 Kudos
1 Reply
ClintDow
Occasional Contributor

I got an answer to this over at StackExchange, basically the event isn't implemented for the TOC. There's a couple 'hack' workarounds to get more or less the same functionality, but in my case I have used this information to explain to my team lead why adding a button and click event will be more suitable to our needs.

0 Kudos