2

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);
  }      
2

You should wire the IActiveViewEvents.ItemDeleted Event.

https://desktop.arcgis.com/en/arcobjects/latest/net/webframe.htm#IActiveViewEvents_ItemDeleted.htm

From there you can control what happens, whether a refresh, partial refresh, or nothing.

For help on wiring events: https://desktop.arcgis.com/en/arcobjects/latest/net/webframe.htm#8dbe2ce3-f2cc-497e-8a6f-b89ab93d1373.htm

  • Hi. I added and Wired the Event Handler and here is where I am catching it. I used Partial Refresh, and also left every thing Blank. But it is still Refresh. private void OnActiveViewEventsItemDeleted(object Item) { // Add your code here //System.Windows.Forms.MessageBox.Show("ItemDeleted"); mpMxDoc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewNone, null, null); } – Hussain Nov 15 '16 at 16:38
0

I tired following and has worked for me.

I set the DelayUpdateContents property on IMxDocument and it has done the trick !

mpMxDoc.DelayUpdateContents = true;

Thanks for all the replies.

Hussain

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.