Dim pLR As ILocatorRectangle Dim pMFRef As IMapFrame pGraphContainer.Reset() pElement = pGraphContainer.Next While Not pElement Is Nothing If TypeOf pElement Is IMapFrame Then pMapFrame = pElement If pMapFrame.LocatorRectangleCount > 0 Then pLR = pMapFrame.LocatorRectangle(0) pMFRef = pLR.MapFrame pMapFrame.ExtentType = ESRI.ArcGIS.Carto.esriExtentTypeEnum.esriExtentScale pMapFrame.MapScale = df.Scale 'edit to desired scale pMapFrame.ExtentType = ESRI.ArcGIS.Carto.esriExtentTypeEnum.esriExtentDefault End If End If pElement = pGraphContainer.Next End While Next
Dim pLR As ILocatorRectangle Dim pMFRef As IMapFrame pGraphContainer.Reset() pElement = pGraphContainer.Next While Not pElement Is Nothing If TypeOf pElement Is IMapFrame Then pMapFrame = pElement If pMapFrame.LocatorRectangleCount > 0 Then pEnv = pElement.Geometry.Envelope pLR = pMapFrame.LocatorRectangle(0) pMFRef = pLR.MapFrame pMapFrame.ExtentType = ESRI.ArcGIS.Carto.esriExtentTypeEnum.esriExtentBounds pMapFrame.MapBounds = pMFRef.MapBounds 'resetting the size here stops the scale from being slightly off on resize. pMapFrame.ExtentType = ESRI.ArcGIS.Carto.esriExtentTypeEnum.esriExtentDefault pElement.Geometry = pEnv 'Reset the position of the dataframe. pMapFrame.ExtentType = ESRI.ArcGIS.Carto.esriExtentTypeEnum.esriExtentScale pMapFrame.MapScale = df.Scale 'edit to desired scale pMapFrame.ExtentType = ESRI.ArcGIS.Carto.esriExtentTypeEnum.esriExtentDefault End If End If pElement = pGraphContainer.Next End While Next
Oops - sorry I just did a really bad job of cut and paste with the code. Below is hopefully slightly less bad...
It is worth mentioning that this code has changed behavior between ArcGIS versions and turned out to be a bug. I'm posting it to demonstrate one method to jump from one map frame to another related map frame.Dim pLR As ILocatorRectangle Dim pMFRef As IMapFrame pGraphContainer.Reset() pElement = pGraphContainer.Next While Not pElement Is Nothing If TypeOf pElement Is IMapFrame Then pMapFrame = pElement If pMapFrame.LocatorRectangleCount > 0 Then pEnv = pElement.Geometry.Envelope pLR = pMapFrame.LocatorRectangle(0) pMFRef = pLR.MapFrame pMapFrame.ExtentType = ESRI.ArcGIS.Carto.esriExtentTypeEnum.esriExtentBounds pMapFrame.MapBounds = pMFRef.MapBounds 'resetting the size here stops the scale from being slightly off on resize. pMapFrame.ExtentType = ESRI.ArcGIS.Carto.esriExtentTypeEnum.esriExtentDefault pElement.Geometry = pEnv 'Reset the position of the dataframe. pMapFrame.ExtentType = ESRI.ArcGIS.Carto.esriExtentTypeEnum.esriExtentScale pMapFrame.MapScale = df.Scale 'edit to desired scale pMapFrame.ExtentType = ESRI.ArcGIS.Carto.esriExtentTypeEnum.esriExtentDefault End If End If pElement = pGraphContainer.Next End While Next