Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using IGraphicsContainerEvents_ElementAddedEventHandler to do stuff with graphics added by users in an ArcMap session using the standard drawing toolbar. As the code snippet below shows, its a pretty straight-forward process, and works perfect for the first few (2-3) graphics added. However, eventually 'ElementAdded' stops firing for no apparent reason (i.e no errors that I can catch).

Does anyone have any idea of what would be unregistering the listener (OnElementAdded) and/or preventing the ElementAdded event to be fired?

ICompositeGraphicsLayer activeGraphicsLayer = (ICompositeGraphicsLayer)mxDoc.ActiveView.FocusMap.ActiveGraphicsLayer;
IGraphicsContainerEvents_Event containerEvents = (IGraphicsContainerEvents_Event)activeGraphicsLayer;
containerEvents.ElementAdded += new IGraphicsContainerEvents_ElementAddedEventHandler(OnElementAdded);

private void OnElementAdded(IElement Element)
// do stuff
share|improve this question
Are you re-wiring this event handler when the active view changes? – Kirk Kuykendall Mar 13 '12 at 16:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.