[GIS] Labeling Selected Features Only using ArcGIS Engine

arcgis-10.0arcgis-enginearcobjectsc

I've been labeling using the LabelEngine and simple expressions and it is working for every layer. I want to offer the option of labeling only selected features and thought it would be this simple:

annotateLayerProperties.LabelWhichFeatures = esriLabelWhichFeatures.esriSelectedFeatures;

Unfortunately that doesn't do it. Every polygon is still labeled. I verified that the features were selected (I have a routine that just returns the selected keys.) I also tried replacing the Engine labeling with a:

annotateLayerProperties.WhereClause = BuildWhere( keyName, selected );

using both my keys and the features OIDs – that does not label at all.

Does anyone know how to label only the selected features?

Best Answer

Labeling selected features is not currently possible in ArcGIS. The value you are setting on the property LabelWhichFeatures is overwritten by the labeling process and is not intended to be a persisted setting for this purpose. It main exists to power Convert Labels to Annotation which has a selected features option.

There is an existing enhancement request to provide labeling for selected features, but we'd like to understand the workflows that people are trying to fulfill with this requested functionality. If you can provide any details here, it would be helpful. <- If it is not obvious, I work on labeling at Esri.