AnsweredAssumed Answered

Show relates from destination layer/table

Question asked by fferrazzaesriitalia-it-esridist Employee on Sep 10, 2015

Hi all,

i need to know by arcobjects which other layers/tables are related throught relationship classes or throught relates to an other.

 

For relationship classes there are no problems.

For relates, if I query the origin layer is ok, but if i query the destination layer, the relate has not shown.

 

Here a little code example:

 

                 ILayer lay=ArcMap.Document.SelectedLayer;

            IRelationshipClassCollection relClasses = lay as IRelationshipClassCollection;

            IFeatureClass fc = ((IFeatureLayer)lay).FeatureClass;

            IEnumRelationshipClass enumRelC=relClasses.RelationshipClasses;

 

            enumRelC.Reset();

 

            IRelationshipClass relC = enumRelC.Next() as IRelationshipClass;

 

            if (relC == null)

            {

                MessageBox.Show("NoRel");

                return;

            }

 

            while (relC != null)

            {

                MessageBox.Show(relC.OriginClass.AliasName + " "+ relC.DestinationClass.AliasName);

                relC = enumRelC.Next() as IRelationshipClass;

            }

      

So, if the selected layer is the origin for relate, "OriginLay DestinationLay" has shown, if the selected is destination one, "NoRel" has shown instead.

 

Could you help me?

 

Thanks!

 

Fabiano

Outcomes