Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to create a new map frame in the PageLayout Control. But I got the error: Error HRESULT E_FAIL has been returned from a call to a COM component at the method AddElement.

Please see below codes:

                    IEnvelope envelope = new EnvelopeClass();
                    envelope.PutCoords(Upper_LeftX, Upper_LeftY - _Height, Upper_LeftX + _Width,
                        Upper_LeftY);

                    IMap map = new MapClass();

                    IMapFrame mapFrame = new MapFrameClass();
                    mapFrame.Map = map;
                    IElement mapElement = mapFrame as IElement;
                    mapElement.Geometry = envelope;

                    pageControl.ActiveView.GraphicsContainer.AddElement(mapElement  , 0); // throw error
                    pageControl.ActiveView.FocusMap = mapFrame.Map;
                    pageControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

Do you know why ?

Thanks and regards,

Tai

share|improve this question
    
The above error only happen when the pageControl.ActiveView.FocusMap (MapFrame) is being selected –  taibc Nov 6 '12 at 9:49
    
Are there anyone know how to fix it ? –  taibc Nov 8 '12 at 3:48

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.