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);
The above error only happen if the pageControl.ActiveView.FocusMap (MapFrame) is being selected.Do you know how to fix it ?Thanks and regards,Tai