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.
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
}
Hi Duncan and Weifeng and thanks for the answer
I have been working in the next code to get all Subtypes from a table in a single string that concatenate. But I can not put it to works it correctly.
I attached it in the form of an image and text but its the same code.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
IDocument docRDC = m_application.Document;
IMxDocument mxdocRDC = docRDC as IMxDocument;
string esFeature = "";
string esTable = "";
if (mxdocRDC.SelectedItem is IFeatureLayer2)
{
esFeature = "Si";
MessageBox.Show("Es IFeaturelayer2");
}
if (mxdocRDC.SelectedItem is ITable)
{
esTable = "Si";
MessageBox.Show("Es Itable");
}
ITable table = mxdocRDC.SelectedItem as ITable;
System.Text.StringBuilder listadosubtipos = new System.Text.StringBuilder();
if (esFeature != "Si" && esTable=="Si")
{
IObjectClass MiObjeClassTabla = table as IObjectClass;
ISubtypes MisSubtypesTabla = (ISubtypes)MiObjeClassTabla;
IEnumSubtype enumSubtypeTabla;
int subtypeCodeTabla;
string subtypeNameTabla;
if (MisSubtypesTabla.HasSubtype)
{
enumSubtypeTabla = MisSubtypesTabla.Subtypes;
subtypeNameTabla = enumSubtypeTabla.Next(out subtypeCodeTabla);
while (subtypeNameTabla != null)
{
listadosubtipos.Append(subtypeNameTabla);
listadosubtipos.Append(", ");
subtypeNameTabla = enumSubtypeTabla.Next(out subtypeCodeTabla);
}
}
textBox3.Text = Convert.ToString(listadosubtipos);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Thanking any help
IDocument docRDC = m_application.Document;
IMxDocument mxdocRDC = docRDC as IMxDocument;
string esFeature = "";
string esTable = "";
if (mxdocRDC.SelectedItem is IFeatureLayer2)
{
esFeature = "Si";
MessageBox.Show("Es IFeaturelayer2");
}
if (mxdocRDC.SelectedItem is ITable)
{
esTable = "Si";
MessageBox.Show("Es Itable");
}
ITable table = mxdocRDC.SelectedItem as ITable;
System.Text.StringBuilder listadosubtipos = new System.Text.StringBuilder();
if (esFeature != "Si" && esTable=="Si")
{
IObjectClass MiObjeClassTabla = table as IObjectClass;
ISubtypes MisSubtypesTabla = (ISubtypes)MiObjeClassTabla;
IEnumSubtype enumSubtypeTabla;
int subtypeCodeTabla;
string subtypeNameTabla;
if (MisSubtypesTabla.HasSubtype)
{
enumSubtypeTabla = MisSubtypesTabla.Subtypes;
subtypeNameTabla = enumSubtypeTabla.Next(out subtypeCodeTabla);
while (subtypeNameTabla != null)
{
listadosubtipos.Append(subtypeNameTabla);
listadosubtipos.Append(", ");
subtypeNameTabla = enumSubtypeTabla.Next(out subtypeCodeTabla);
}
}
textBox3.Text = Convert.ToString(listadosubtipos);
}
what I am looking for is to get all the subtypes of a stand-alone table. The code "IFeatureClass" it is no working with stand-alone table.