<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Adding mapgrid to existing mapinsets in ArcObjects .Net (C#) in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/adding-mapgrid-to-existing-mapinsets-in-arcobjects/m-p/1000590#M20215</link>
    <description>&lt;P&gt;&lt;SPAN&gt;i&amp;nbsp;&lt;/SPAN&gt;am facing the problem to add a mapgrid to existing map insets created in a pagelayout at an earlier step. I can implement some code in a DLL loaded by reflection to add some operations like adding a north arrow, a legend or modifying existing elements of the pagelayout using an available interface. Up to now I am able to get the created map insets and to create the map grid but I have difficulties to "link" them together.&lt;/P&gt;&lt;P&gt;Here is the code I tried:&lt;/P&gt;&lt;PRE&gt;   for (int i = 0; i &amp;lt; localMap.MapSurroundCount; i++)
   {
               IMapSurround mapSurround = localMap.MapSurround[i];
                if (mapSurround is MapInset)
                {
                    IMapInset mapinset = mapSurround as IMapInset;
                    IFrameElement frameElement = graphicsContainer.FindFrame(mapinset);
                    if (frameElement != null)
                    {
                        ICustomOverlayGrid mapGridCarroyage = new CustomOverlayGridClass();
                        ... 
                        ... setting some properties for  mapGridCarroyage
                        ...
                        IMapFrame mapFrame = frameElement as IMapFrame;
                        IMapGrids mapGrid = mapframe as IMapGrids;
                        mapGrid.AddMapGrid(mapGridCarroyage);
                    }
               }
         
         }&lt;/PRE&gt;&lt;P&gt;mapFrame is always null but localMap.Mapssurround[i] is returning correctly an existing MapInset and frameElement is not null.&lt;/P&gt;&lt;P&gt;What is going on? what am i doing wrong?&lt;/P&gt;</description>
    <pubDate>Thu, 12 Nov 2020 09:22:27 GMT</pubDate>
    <dc:creator>LaurePillet2</dc:creator>
    <dc:date>2020-11-12T09:22:27Z</dc:date>
    <item>
      <title>Adding mapgrid to existing mapinsets in ArcObjects .Net (C#)</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/adding-mapgrid-to-existing-mapinsets-in-arcobjects/m-p/1000590#M20215</link>
      <description>&lt;P&gt;&lt;SPAN&gt;i&amp;nbsp;&lt;/SPAN&gt;am facing the problem to add a mapgrid to existing map insets created in a pagelayout at an earlier step. I can implement some code in a DLL loaded by reflection to add some operations like adding a north arrow, a legend or modifying existing elements of the pagelayout using an available interface. Up to now I am able to get the created map insets and to create the map grid but I have difficulties to "link" them together.&lt;/P&gt;&lt;P&gt;Here is the code I tried:&lt;/P&gt;&lt;PRE&gt;   for (int i = 0; i &amp;lt; localMap.MapSurroundCount; i++)
   {
               IMapSurround mapSurround = localMap.MapSurround[i];
                if (mapSurround is MapInset)
                {
                    IMapInset mapinset = mapSurround as IMapInset;
                    IFrameElement frameElement = graphicsContainer.FindFrame(mapinset);
                    if (frameElement != null)
                    {
                        ICustomOverlayGrid mapGridCarroyage = new CustomOverlayGridClass();
                        ... 
                        ... setting some properties for  mapGridCarroyage
                        ...
                        IMapFrame mapFrame = frameElement as IMapFrame;
                        IMapGrids mapGrid = mapframe as IMapGrids;
                        mapGrid.AddMapGrid(mapGridCarroyage);
                    }
               }
         
         }&lt;/PRE&gt;&lt;P&gt;mapFrame is always null but localMap.Mapssurround[i] is returning correctly an existing MapInset and frameElement is not null.&lt;/P&gt;&lt;P&gt;What is going on? what am i doing wrong?&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 09:22:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/adding-mapgrid-to-existing-mapinsets-in-arcobjects/m-p/1000590#M20215</guid>
      <dc:creator>LaurePillet2</dc:creator>
      <dc:date>2020-11-12T09:22:27Z</dc:date>
    </item>
  </channel>
</rss>

