ILabelEngineLayerProperties not working

Discussion created by pladd on Nov 18, 2011
Latest reply on Nov 18, 2011 by pladd
Like many others, I am trying to use code to label selected features.  I've seen other thread discuss this issue and the solutions are the same but don't seem to work for me.

See here >

And here >

And here >

I have the user select the field name from a combobox.  The selected feature still label, just with the default display field.  Can anybody see what I'm doing wrong?

//Get AnnotateLayerPropertiesCollection from Layer
                IAnnotateLayerPropertiesCollection pAnnoLayerPropsColl = pLayer.AnnotationProperties;
                IAnnotateLayerProperties pAnnoLayerProps;

                IElementCollection placedElements;
                IElementCollection unplacedElements;

                ElementCollection pEnumInVisibleElements = new ElementCollection();

                pAnnoLayerPropsColl.QueryItem(0, out pAnnoLayerProps, out placedElements, out unplacedElements);
                pAnnoLayerProps.Class = "LabelSel";
                pAnnoLayerProps.WhereClause = strSql;
                //display the labels
                ILabelEngineLayerProperties le = new LabelEngineLayerPropertiesClass();
                string exp = "[" + cbFieldNames.SelectedItem.ToString() + "]";
                le.Expression = exp;

                pLayer.DisplayAnnotation = true;
                //refresh the view