Skip to main content
4 of 4
edited tags
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

Change The Label Field In GeoFeatureLayer

I currently have a basic shapefile that's a map of the United States. It has the name of the states, populations, and other pieces of information that I can get the names of via the following code:

IFeatureLayer myFeatureLayer = myLayer as IFeatureLayer;
IFeatureClass myFeatureClass = myFeatureLayer.FeatureClass;

For(int I = 0; I < myFeatureClass.Fields.FieldCount; i++)
{
IField field = myFeatureClass.Fields.get_Field(i);
Console.writeLine(field.Name);
}

The first field in the featureClass (after FID and the shape) is STATE_NAME which obviously is the name of each state.

If I do the following:

IGeoFeatureLayer geoLayer = myLayer as IGeoFeatureLayer;
geoLayer.displayAnnotation = true;

The states are now labeled; however, what I'd like is the ability to show different labels. I know from my looping through the featureclass Field count there are properties such as population and elevation. How do I change the AnnotationProperties to have it display that information instead of the default?

ist_lion
  • 511
  • 1
  • 4
  • 16