Display legend in dockable window

2742
0
10-14-2014 12:51 PM
JosephSaltenberger
New Contributor III

I'm trying to display a legend in a dockable window. I am successful in creating a legend in layout view using the code below. Is there anyway to draw 'MSElement' in a dockable window? Thanks.

ILegend legend = new LegendClass_2();

legend.AutoAdd = true;

legend.Title = "Test";

legend.Map = mxdoc.FocusMap;

IMapSurroundFrame MSFrame = new MapSurroundFrameClass();

MSFrame.MapSurround = legend;

IElement MSElement = MSFrame as IElement;

IEnvelope en = new EnvelopeClass();

en.XMin = 1.5; en.YMin = 1.5;

en.Width = 10; en.Height = 10;

MSElement.Geometry = en as IGeometry;

IGraphicsContainer gc = mxdoc.PageLayout as IGraphicsContainer;

gc.AddElement(MSElement, 0);

           

mxdoc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphic

s, null, null);

0 Kudos
0 Replies