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.Name == scenarioName) { m_maps.Item.Expanded = true; } } activateDataFrame(scenarioName); }
Solved! Go to Solution.
If the selected element is one of the layers, the dataframe with the selected layer stays expanded.
private void expandScenario(string scenarioName) { //collapse all data frames for (int i = 0; i < m_maps.Count; i++) { IGraphicsContainerSelect graphics = (IGraphicsContainerSelect)m_maps.Item; graphics.UnselectAllElements(); m_maps.Item.Expanded = false; } //expand the scenario's data frame for (int i = 0; i < m_maps.Count; i++) { if (m_maps.Item.Name == scenarioName) { m_maps.Item.Expanded = true; } } activateDataFrame(scenarioName); }
Sub test() Dim mxd As IMxDocument Set mxd = ThisDocument Dim i As Integer For i = 0 To mxd.Maps.Count - 1 mxd.Maps.Item(i).Expanded = False Next mxd.UpdateContents End Sub
If the selected element is one of the layers, the dataframe with the selected layer stays expanded.
private void expandScenario(string scenarioName) { //collapse all data frames for (int i = 0; i < m_maps.Count; i++) { IGraphicsContainerSelect graphics = (IGraphicsContainerSelect)m_maps.Item; graphics.UnselectAllElements(); m_maps.Item.Expanded = false; } //expand the scenario's data frame for (int i = 0; i < m_maps.Count; i++) { if (m_maps.Item.Name == scenarioName) { m_maps.Item.Expanded = true; } } activateDataFrame(scenarioName); }
Dim mxd As IMxDocument Set mxd = ThisDocument Dim ctView As IContentsView Set ctView = mxd.ContentsView(0) ctView.RemoveFromSelectedItems (ctView.SelectedItem) Dim i As Integer For i = 0 To mxd.Maps.Count - 1 mxd.Maps.Item(i).Expanded = False Next mxd.UpdateContents