Legend Background Frame Does Not Update

1296
5
07-08-2010 03:18 AM
SimonEarnshaw
New Contributor III
I have a Legend in my PageLayout it has a black border and white background.

I am referencing the mxd via IMapDocument outside of ArcGIS envionment (Arc Engine).

When I programmatically change the layers that are visible the legend updates automatically and shrinks and grows accordingly (great!) - however the background frame does not and just stays as it was initially set when the mxd was saved (this is not great).  This makes my legend look really bad.

Look at attached word doc to see what is happening.

Does anyone know how to stop this happening or does anyone know how to update in code the background frame?
0 Kudos
5 Replies
KirkKuykendall
Occasional Contributor III
are you calling ILegend2.Refresh?
0 Kudos
SimonEarnshaw
New Contributor III
Yep - and it has absolutely no effect.  I have tried so many different ways of calling it and combining it with an acitiveview.Refresh and so on - absolutely will not change from it's initial size.
0 Kudos
KirkKuykendall
Occasional Contributor III
Maybe try calling ITransform2D.Move(0,0) on the legend's mapsurroundframe.

If 0,0 doesn't work, try moving twice, once forward, and then backwards.
0 Kudos
SimonEarnshaw
New Contributor III
Maybe try calling ITransform2D.Move(0,0) on the legend's mapsurroundframe.

If 0,0 doesn't work, try moving twice, once forward, and then backwards.


Tried it like this - but it didnt work...

           
IGraphicsContainer graphicsContainer = (IGraphicsContainer)MapDocument.PageLayout;
            graphicsContainer.Reset();

            IElementProperties2 elementProperties = (IElementProperties2)graphicsContainer.Next();

            while (elementProperties != null)
            {
                if (elementProperties.Name == "LEGEND")
                {
                    IMapSurroundFrame mapSurroundFrame = (IMapSurroundFrame)elementProperties;
                    ILegend2 legend = (ILegend2)mapSurroundFrame.Object;
                    

                    ITransform2D trans = (ITransform2D) mapSurroundFrame;
                    trans.Move(0, 0);
                    trans.Move(1, 0);
                    trans.Move(-1, 0);
                    trans.Move(0, 0);

                    mapSurroundFrame.MapSurround.Refresh();
                    legend.Refresh();
                    return;
                    }
             elementProperties = (IElementProperties2)graphicsContainer.Next();
            }
0 Kudos
KirkKuykendall
Occasional Contributor III
That's strange ... maybe get the geometry returned by ILegend2.QueryBounds and assign it to IElement.Geometry.
0 Kudos