I tried to get IGraphicsContainer from Data View (active map) using FocusMap, ActiveView

IGraphicsContainer graphicsContainer = (IGraphicsContainer)neApp.Document.MxDocument.FocusMap;

but the variable always null, is there any different way to do this?

I already get from page layout view in this question right here: Get IGraphicsContainer from page layout but i need it from data view (map).


The Map class does implement IGraphicsContainer, so most likely the problem is in the expression neApp.Document.MxDocument.FocusMap. Make sure it does not return null.

Also be aware that a map can contain multiple graphic layers. See the discussion in IMap.BasicGraphicsLayer documentation for details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.