I have two points, Ipoint upperRight; and Ipoint lowerLeft; points.

from the previous points i can get the height and the width for the rectangle.

How can i draw a rectangle on the map?.

I think i should use IGraphicsContainer.AddElement Method, but i don't know how, i searched through the internet but didn't find any useful example.

1 Answer 1


This is the code to draw a rectangle to page layout view.

IEnvelope env = element.Geometry.Envelope;

if (env != null) {
IPageLayout pLayout = activeView as IPageLayout;
IGraphicsContainer graphicsContainer = pageLayout as IGraphicsContainer;
IRectangleElement rectangleElement = new RectangleElementClass();
IElement elem = rectangleElement as IElement;
elem.Geometry = env;
graphicsContainer .AddElement(elem, 0);
activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

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.