Sunday, 4 December 2016

arcgis 10.0 - How to group layers in ArcEngine 10


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



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.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...