I'm stuck on how to collapse all layers in my ArcMap projects (9.3). I've tried a few bits of sample code, but they all seem to fail for some reason or other.
Some of the layers might be grouped, and some are imagery or WMS layers if that makes a difference.
Here is some code I have tinkered with, but does not work:
Dim pMxdoc As IMxDocumentSet pMxdoc = ThisDocumentDim pFeatLayer As IFeatureLayerDim pEditLayers As IEditLayersSet pEditLayers = pEditorDim pMap As IMapSet pMap = pMxdoc.FocusMapDim pLayer As ILayer'Collapse any expanded grouplayersDim pGroupLayer As IGroupLayerFor i = 0 To pMxdoc.FocusMap.LayerCount - 1Set pLayer = pMxdoc.FocusMap.Layer(i)'Check if the reached layer is a groupIf TypeOf pLayer Is IGroupLayer Then Set pGroupLayer = pLayer if pGroupLayer.Expanded = true Then pGroupLayer.Expanded = false End ifEnd IfNext ipMxdoc.UpdateContentspMxdoc.ActiveView.Refresh
أكثر...
Some of the layers might be grouped, and some are imagery or WMS layers if that makes a difference.
Here is some code I have tinkered with, but does not work:
Dim pMxdoc As IMxDocumentSet pMxdoc = ThisDocumentDim pFeatLayer As IFeatureLayerDim pEditLayers As IEditLayersSet pEditLayers = pEditorDim pMap As IMapSet pMap = pMxdoc.FocusMapDim pLayer As ILayer'Collapse any expanded grouplayersDim pGroupLayer As IGroupLayerFor i = 0 To pMxdoc.FocusMap.LayerCount - 1Set pLayer = pMxdoc.FocusMap.Layer(i)'Check if the reached layer is a groupIf TypeOf pLayer Is IGroupLayer Then Set pGroupLayer = pLayer if pGroupLayer.Expanded = true Then pGroupLayer.Expanded = false End ifEnd IfNext ipMxdoc.UpdateContentspMxdoc.ActiveView.Refresh

أكثر...