Select to view content in your preferred language

Legend Background Frame Does Not Update

1601
5
07-08-2010 03:18 AM
SimonEarnshaw
Occasional Contributor
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
Deactivated User
are you calling ILegend2.Refresh?
0 Kudos
SimonEarnshaw
Occasional Contributor
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
Deactivated User
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
Occasional Contributor
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
Deactivated User
That's strange ... maybe get the geometry returned by ILegend2.QueryBounds and assign it to IElement.Geometry.
0 Kudos