ArcGIS Engine .NET add labels to a layer.

Discussion created by cpmikey21 on Jul 29, 2010
I have a .NET engine application where I would like to show labels on a layer.  I am not sure if labels is the correct term, perhaps annotations?  Something which will show some information on the map such as a name for a feature.  After searching for a couple of days now, I have only found out how to show the MapTips, not something which will show all of the time.

What I currently have is the following which doesn't work.  Any ideas which piece I am missing?

        Dim objLblEngineLyrProps As ILabelEngineLayerProperties
        Dim objAnnoLyrPropsColl As IAnnotateLayerPropertiesCollection
        Dim objAnnoLyrProps As IAnnotateLayerProperties
        Dim objRGBColor As IRgbColor

        Dim obj As IGeoFeatureLayer
        'objAnnoLyrProps = New LabelEngineLayerProperties
        objRGBColor = New RgbColor
        objRGBColor.Red = 0
        objRGBColor.Green = 0
        objRGBColor.Blue = 128
        objLblEngineLyrProps = New LabelEngineLayerProperties
        objLblEngineLyrProps.Expression = "STATE_NAME"
        objLblEngineLyrProps.Symbol.Color = objRGBColor
        objLblEngineLyrProps.Symbol.Size = 20.0
        objAnnoLyrProps = TryCast(objLblEngineLyrProps, IAnnotateLayerProperties)
        objAnnoLyrProps.LabelWhichFeatures = esriLabelWhichFeatures.esriVisibleFeatures
        'objAnnoLyrPropsColl = objGeoFeatureLayer.AnnotationProperties
        'objGeoFeatureLayer.AnnotationProperties = objAnnoLyrPropsColl
        objGeoFeatureLayer.DisplayAnnotation = True
        objAnnoLyrProps.DisplayAnnotation = True