Original ae+c# add legend to AxPageLayoutControl1
//Get the GraphicsContainerIgraphicscontainer GraphicsContainer =Axpagelayoutcontrol1.graphicscontainer;//Get the MapframeImapframe Mapframe =(Imapframe) graphicscontainer.findframe (AXPAGELAYOUTCONTROL1.ACTIVEVIEW.FOCUSMAP);if(Mapframe = =NULL)return;//Create a legendUID UID =NewUidclass (); Uid.value="Esricarto.legend";//Create a mapsurroundframe from the MapframeImapsurroundframe mapsurroundframe = Mapframe.createsurroundframe (UID,NULL);if(Mapsurroundframe = =NULL)return;if(Mapsurroundframe.mapsurround = =NULL)return;//Set the nameMapSurroundFrame.MapSurround.Name ="Legend";//Envelope for the legendIenvelope envelope =NewEnvelopeclass (); envelope. Putcoords (1,1,3.4,2.4);//Set The geometry of the Mapsurroundframeielement element =(ielement) mapsurroundframe;element. Geometry=envelope;//ADD The legend to the pagelayoutAxpagelayoutcontrol1.addelement (element, Type.Missing, Type.Missing,"Legend",0);//Refresh the PagelayoutcontrolAxPageLayoutControl1.ActiveView.PartialRefresh (Esriviewdrawphase.esriviewgraphics,NULL,NULL);
Ae+c# adding a legend to AxPageLayoutControl1