ArcGIS 10.0 – How to Group Layers in ArcEngine 10 for Better Data Management

arcgis-10.0arcgis-engine

I was wondering if there is a way I can code the TOC control so that I can select multiple layers and GROUP them together. So if i uncheck the group, all layers will be unchecked and be invisible.

Thanks and Regards,
Kevin

Best Answer

You probably need to do some coding, because I haven't seen anything similar to the ArcMap Group context menuitem in engine.

But you should be able to do this with a group layer.

One way would be to create a group layer and add the layers in the group layer instead of the map and add the group layer to the map. Don't forget to fire the ContentsChanged() on the Active View otherwise the Toc will not be refreshed and PartialRefresh(esriViewAll,Nothing,Nothing) to update the map.

An other way would be to move the layers to the newly created group layer, see the question rearrange layers. To find out the layers that get clicked you need to use the HitTest, check out the context menu sample on how to use hit testing.