Below is my code where I am first collecting graphic elements to delete, and then iterating the list to delete the elements. Issue is that the ArcGIS gets refreshed after every delete graphContainer.DeleteElement(item). How can I prevent it for automated refresh.
IActiveView activeView = pMxDoc.ActiveView;
IPageLayout pageLayout = activeView as IPageLayout;
IGraphicsContainer graphContainer = pageLayout as IGraphicsContainer;
graphContainer.Reset();
IElement pElement;
List<IElement> toDel = new List<IElement>();
pElement = graphContainer.Next();
while (pElement != null)
{
//if (pElement is ITextElement)
if (pElement is IMapFrame)
{
}
else
{
toDel.Add(pElement);
}
pElement = graphContainer.Next();
}
foreach (IElement item in toDel)
{
graphContainer.DeleteElement(item);
}