[GIS] Using Arc Objects to collapse a layer in the map TOC

arcobjects

I have the following snippit of code to perform this. However, it doesn't do anything to the layer in the TOC on the map that gets generated from this code. When the layer is created and the map shows up, the layer appears expanded. I want it to collapse. Am I doing something wrong? Thanks.

        IMap aMap = axMapControl1.ActiveView.FocusMap;
        ILayer pLayer = aMap.get_Layer(0);
        INALayer2 anNALyr = (INALayer2)pLayer;
        anNALyr.Expanded = false;
        axTOCControl1.Refresh();

Also, how do I get a layer in the TOC to move to the bottom of the TOC?

Best Answer

You're question is similar to mine: Programmatically uncheck layer in AxTOCControl

The solution was to use the correct refresh method: IActiveView.ContentsChanged

For layer movement, use mapcontrol.map.MoveLayer()

Related Question