scottdizzy

refresh erases elements in layout view

Discussion created by scottdizzy on Apr 12, 2011
Latest reply on Apr 12, 2011 by scottdizzy
Hi, I was using the ZoomtoLayer example and it works fine in data view, but does not work in Layout view.  It erases my whole screen, the elements, layers, page etc and it doesn't come back.  I have to close out the application and start over.  Thanks for your help!

public static void zoomToLayerByName(IActiveView activeView, string sName)
        {  
            if (activeView == null || sName == null)
            {
                MessageBox.Show("zoomToLayer: Layer " + sName + " not found.");
                return;
            }                   
                IMap map = activeView.FocusMap;
                Int32 layerIndex = GetIndexNumberFromLayerName(activeView, sName);

               if (layerIndex >= map.LayerCount || layerIndex == -1)
                {
                    MessageBox.Show("zoomToLayer: Layer " + sName + " not found.");
                    return;
                }
            activeView.Extent = map.get_Layer(layerIndex).AreaOfInterest;
            activeView.PartialRefresh(esriViewDrawPhase.esriViewBackground,null, null);
        }

Oh, and I also tried a full refresh or partial with esriViewAll.  Neither helped.
Thanks!
Scott

Outcomes