I draw a polygon on button click to highlight a feature. Then I need to refresh the ActiveView to show the new polygon. This lines do work:

mapControl.ActiveView.ScreenDisplay.StartDrawing(StartDrawing(mapControl.ActiveView.ScreenDisplay.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache);
mapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewAll, feature.Extent, null);

But it always reloads every layer. I tried nearly all ways of calling PartialRefresh with other esriViewDrawPhase but none of them did show the new polygon.

Is there a better solution than to redraw with esriViewDrawPhase.esriViewAll?


I used an ILayerExtensionDraw.AfterDraw to test the draw phases and the AfterDraw only gets hit for PartialRefresh() with esriViewAll. The extension is added to all layers in MapControl.Layers. I expected that it gets hit everytime? On which layer does mapControl.ActiveView.ScreenDisplay.DrawPolygon(feature.Shape); draw so that the AfterDraw isn't even raised?


Thanks to Kirk here is the solution, which shows the new added graphic without reloading any layer.

IGraphicsContainer con = _mapControl.Map as IGraphicsContainer;
if (con != null)
  IFillShapeElement fillShapeElement = new PolygonElementClass();
  fillShapeElement.Symbol = fillSymbol;
  IElement element = (IElement)fillShapeElement;
  element.Geometry = feature.Shape;
  con.AddElement(element, 0);
  _mapControl.ActiveView.ScreenDisplay.Invalidate(feature.Extent, true, _mapControl.ActiveView.get_ScreenCacheID(esriViewDrawPhase.esriViewGraphics, null));
  • 1
    [I think the ESRI documentation is wishful not descriptive.][1] [1]: gis.stackexchange.com/questions/17422/remove-layer-labels – Chaz Jan 30 '12 at 15:42
  • 1
    Since you are drawing directly to the display (esriScreenCache.esriNoScreenCache), you should not need to refresh at all. In fact refreshing would cause the graphic to disappear. Have you tried without the PartialRefresh line? – blah238 Jan 30 '12 at 19:55
  • Try esriViewDrawPhase.esriViewGeography instead of esriViewAll – patrick Jan 30 '12 at 20:13
  • @blah238 It's not showing up without a (Partial)Refresh. – gumo Jan 31 '12 at 8:22
  • @iterationx I tested all values, but only esriViewAll worked for me. – gumo Jan 31 '12 at 8:30

I would try calling IScreenDisplay.InValidate, and pass in a cacheID for esriViewGraphics using IActiveView.ScreenCacheID. Do this after adding the graphics to the map by casting the map to IGraphicsContainer, and adding via AddElement.

  • 1
    Thanks, it works. I didn't know I could use Invalidate() with unchached layers. See my update for implementation details. – gumo Jan 31 '12 at 11:12

You need to check out the phases: I think esriViewDrawPhase.esriViewGraphics would do the trick for you. But you can also combine phases with a bitwise OR.


  • 1
    In addition, one can use the envelope argument to further restrict the region which should be refreshed. – Petr Krebs Jan 30 '12 at 13:16
  • Jay, esriViewGraphics was my first thought, too, but it doesn't work. So I tried all the other DrapPhases and only esriViewAll shows the Polygon but also reloads all layers. – gumo Jan 30 '12 at 13:20
  • Thanks Petr, I guess you mean using feature.Extent as second argument. I tried that with no success. I think it's a question of the right DrawPhase or maybe there is a totally different approach I don't know of. – gumo Jan 30 '12 at 13:26
  • @gumo: just noticed the arcengine tag. I'm not familiar with the ArcEngine or it screen behavior (maybe it's different). I'll delete this question if/when ArcEngine-specific answers appear. – Jay Cummins Jan 30 '12 at 13:45
  • 1
    Do you have the StartDrawing and FinishDrawing calls? – Jay Cummins Jan 30 '12 at 13:47

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.