This document is archived and information here might be outdated.  Recommended version.


Delete Graphics Refresh ActiveView Snippet (ArcObjects .NET 10.5 SDK)
ArcObjects Library Reference

Delete Graphics Refresh ActiveView Snippet

Delete all the graphics in the GraphicsContainer and refresh the ActiveView.

[C#]
///<summary>
///Delete all the graphics in the GraphicsContainer and refresh the ActiveView.
///</summary>
///<param name="activeView">An ESRI.ArcGIS.Carto.IActiveView interface that will have the graphics deleted and refreshed.</param>
///<remarks></remarks>
public void DeleteGraphicsRefreshActiveView(ESRI.ArcGIS.Carto.IActiveView activeView)
{

  ESRI.ArcGIS.Carto.IGraphicsContainer graphicsContainer=activeView.GraphicsContainer;
  graphicsContainer.DeleteAllElements();
  activeView.Refresh();

}
[Visual Basic .NET]
'''<summary>
'''Delete all the graphics in the GraphicsContainer and refresh the ActiveView.
'''</summary>
'''<param name="activeView">An ESRI.ArcGIS.Carto.IActiveView interface that will have the graphics deleted and refreshed.</param>
'''<remarks></remarks>
Public Sub DeleteGraphicsRefreshActiveView(ByVal activeView As ESRI.ArcGIS.Carto.IActiveView)

  Dim graphicsContainer As ESRI.ArcGIS.Carto.IGraphicsContainer=activeView.GraphicsContainer
  graphicsContainer.DeleteAllElements()
  activeView.Refresh()

End Sub

Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.Carto
  • ESRI.ArcGIS.System