Select to view content in your preferred language

Get Layers with Relates?

2435
4
01-17-2011 02:21 PM
CaleBerkey
Emerging Contributor
Using ArcMap, I'm having a bit of trouble with ArcObjects finding each layer in the TOC that has a relate defined.  Can anyone point me in the right direction for looping through my layers and finding those that have relates defined on them?

Additionally/alternatively, I'll want access on a per-feature basis: for a given relate, returning related attributes for a selected feature. 

Thanks!
0 Kudos
4 Replies
JeffreyHamblin
Occasional Contributor
Here's one way to check if there are relate:

Get an ILayer from a loop of TOC layers.
Cast ILayer to an IRelationshipClassCollection.
Point an IEnumRelationshipClass at the IRelationshipClassCollection.RelationshipClasses.
Get the first IRelationshipClass from IEnumRelationshipClass.Next.
If IRelationshipClass is null then there are no relationships for that layer.

-Jeff
0 Kudos
CaleBerkey
Emerging Contributor
Thanks for your reply, Jeff.  I stumbled across a very similar approach shortly after writing my post, so I'm very happy to see how it resembles your suggestion.
0 Kudos
SteveFang
Deactivated User
Hey Cale, how's it going?  Nice to bump into you on the forum.

Steve
0 Kudos
CaleBerkey
Emerging Contributor
Hey Steve, great to hear from you!

Been out of GIS for a while, since I left you guys, but now back in the fold trying to remember everything I learned a few years ago.  Nice to see the tighter integration with Visual Studio and .NET these days!

I recently talked with Sue - feel free to get my email from her and drop me a line.  I'd be curious what you guys are up to these days!

C
0 Kudos