How to get subtypes from tables in arcobjects

1738
3
09-10-2019 08:38 AM
Ruben_DarioCalero_Clavijo
New Contributor II

Hello

Everyone

I have a problem to get the subtypes from tables in arcmap with the arcobjects library in C# (sharp) lenguage.

So i need that someone could help me with some code example.

Appreciating the attention

0 Kudos
3 Replies
DuncanHornby
MVP Notable Contributor

Have a look at this page on the API help file, whilst it's about creating subtypes you should be able to figure out how to access existing subtypes.

0 Kudos
WeifengHe
Esri Contributor
public void GetSubtypes(IFeatureClass featureClass) {     // Cast the feature class to the ISubtypes interface.    ISubtypes subtypes = (ISubtypes)featureClass;      // then you can enumeraate subtypes.    IEnumSubtype enumSubtype = subtypes.Subtypes
}
0 Kudos
KunalSeth
New Contributor II

You Can Use the Following Code (C#) -

 

//here item is a IfeatureClass

ISubtypes subtypes = item as ISubtypes;
if (subtypes.HasSubtype)
{
IEnumSubtype enumSubtype = subtypes.Subtypes;
enumSubtype.Reset();
int subcode = -1;
string subdesc = enumSubtype.Next(out subcode);
while (!string.IsNullOrEmpty(subdesc))
{
subdesc = enumSubtype.Next(out subcode);

 

//str3 is a string (empty)
str3 = subdesc;

}

}

 

//in this above code you can able to find subtype names associated with each featurelayer 

0 Kudos