Legend and Envelope in 10 SP3

488
1
12-08-2011 09:40 AM
SteveClark
New Contributor III
Something has changed in programmatically creating legends in a pagelayout in SP3. In SP2, I would define an envelope and the legenditems (broken into multiple columns, if necessary) would fit into the envelope. The same code in SP3 doesn't do that anymore. This is from a custom map generator where there could be anywhere from 1 to 40+ legenditems. How do I get this to work again in SP3 where the legenditems expand/contract to the envelope?

                IGraphicsContainer graphicsContainer = pageLayout as IGraphicsContainer;
                IMapFrame mapFrame = graphicsContainer.FindFrame(map) as IMapFrame;
                ESRI.ArcGIS.esriSystem.IUID uid = new ESRI.ArcGIS.esriSystem.UIDClass();
                uid.Value = "esriCarto.Legend";
                IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame((ESRI.ArcGIS.esriSystem.UID)uid, null);
                ILegend pLegend = (ILegend)mapSurroundFrame.Object;


                ...(code to weed out legenditems and break into multiple columns)...

                IEnvelope envelope = new EnvelopeClass();
                envelope.PutCoords(8.8, 0.85, (8.8 + 5.95), (0.85 + 1.45));
                IElement pLegendElement = mapSurroundFrame as IElement; 
                pLegendElement.Geometry = envelope;
                graphicsContainer.AddElement(pLegendElement, 0);
0 Kudos
1 Reply
mikeharol1
New Contributor II
i encountered the same problem, hope there is a solution
0 Kudos