How to redraw the display

This article explores the use of refresh versus invalidate to redraw the display.

In this topic

Redrawing the display

To cause a display to redraw, the invalidate routine must be called; however, most clients never use IScreenDisplay.Invalidate. If there is a view being used in your application—for example, the Map or PageLayout class—the view should be used for refreshing the screen; for example, Refresh and PartialRefresh. The view manages the display's caches and knows the best way to carry out invalidation. Make sure PartialRefresh is called using the most specific arguments possible. Also, only call Refresh when absolutely necessary, since this is usually a time-consuming operation.

One-stop invalidation

To allow views (Map and PageLayout) to completely manage display caching, all invalidation must go through the view. Calling IActiveView.Refresh always draws everything, which is very inefficient. The PartialRefresh method should be used whenever possible. It lets you specify the part of the view to redraw and allows the view to work with display caches in a way that makes drawing quick and efficient.
The following table shows the arguments for PartialRefresh and their effect on the view—Map or PageLayout class—in which they are called:
Draw phase
page/snap grid
feature selection
graphic selection
element selection
map guides
The following code example shows some calls to the PartialRefresh method; note the use of optional arguments:
//Refresh a single Layer 
pMap.partialRefresh(esriViewDrawPhase.esriViewGeography, pLayer, null);

//Refresh All Layers
pMap.partialRefresh(esriViewDrawPhase.esriViewGeography, null, null);

//Refresh Selection
pMap.partialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);

//Refresh Labels
pMap.partialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

//Refresh a single Element
pLayout.partialRefresh(esriViewDrawPhase.esriViewGraphics, pElement, null);

//Refresh All Elements
pLayout.partialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

//Refresh Selection
pLayout.partialRefresh(esriViewDrawPhase.esriViewGraphicSelection, null, null);
Invalidating any phase will cause the recording cache to be invalidated. To force a redraw from the recording cache, use the call in the following code example:
pScreenDisplay.invalidate(null, false, esriScreenCache.esriNoScreenCache);

See Also:

How to add display caching

Development licensingDeployment licensing
ArcGIS for Desktop BasicArcGIS for Desktop Basic
ArcGIS for Desktop StandardArcGIS for Desktop Standard
ArcGIS for Desktop AdvancedArcGIS for Desktop Advanced
Engine Developer KitEngine