AnsweredAssumed Answered

Last map added won't collapse

Question asked by spencerrecneps on Feb 29, 2012
Latest reply on Mar 1, 2012 by agray1
I'm having an issue with using Arcobjects to expand/collapse maps (data frames) in the TOC based on a selected value in a combo box. When a user changes the selection in the combo box, all maps should collapse except for the map that shares a name with the selected combo box. This works well with 1 or 2 maps in the document. With each additional map beyond 2, the last map added does not collapse.

For example, assume 2 maps - Map A and Map B. Expand collapse works well. If I add Map C and change the combo box to "Map A", only Map B collapses. If I add Map D and then change the combo box to "Map B", all maps collapse except Maps B and D.

        private void expandScenario(string scenarioName)         {             //collapse all data frames             for (int i = 0; i < m_maps.Count; i++)             {                 m_maps.Item.Expanded = false;             }             //expand the scenario's data frame             for (int i = 0; i < m_maps.Count; i++)             {                 if (m_maps.Item[i].Name == scenarioName)                 {                     m_maps.Item[i].Expanded = true;                 }             }             activateDataFrame(scenarioName);         }

I have ensured that the document is being updated via [I]IMxDocument.UpdateContents() after making the call. I've checked to make sure the m_maps.Count accurately reflects the number of data frames. I have also checked to make sure m_maps.Item.Expanded = false is being run on the data frame that fails to collapse.

I have noticed that the data frame in question collapses immediately if I move its position in the TOC - perhaps I need to refresh the TOC but I thought calling [I]IMxDocument.UpdateContents()
took care of that.