HandsomePete

Get 'Parent' Group Layers for an ILayer

Discussion created by HandsomePete on Sep 24, 2013
Latest reply on Sep 24, 2013 by HandsomePete
I'm creating an add-in for 10.0 in C#.  Users will be working in MXD's that have nested group layers.  They'll select a layer in the TOC to work on.  In code, I get the selected layer in the TOC, and what I need to do is get the parent layers of the selected layer. 

I have a good handle on looping through each top level layer in the map, and then each sublayer and so on, but that's going from the 'top down,' so to speak.  I want to go from the 'bottom up.'  From the child layer, get each parent. 

For example, say I have the following structure in my table of contents.

Main Campus
-> Engineering Compound            (Group Layer)
----> Building 101                      (Group Layer)
---------> Floor 1                     (Group Layer)
---------------> Classrooms       (Feature Class)
---------------> Offices            (Feature Class)
---------------> Storage Rooms (Feature Class)

Imagine there are many compounds and many buildings in each compound.  If a user selects Classrooms, I want to get Floor 1/Building 101/Engineering Compound/Main Campus.

Any help would be appreciated.

-Brendan

Outcomes