You are here: > ESRI Forums > arcgis engine forums > Thread Replies

ArcGIS Engine Forums

ArcGIS Engine: ArcObjects .NET API forum

How do I change a Label Field of a feature...   Anthony Daniels Feb 13, 2006
Re: How do I change a Label Field of a feat...   Jim Fiddes Feb 13, 2006
Re: How do I change a Label Field of a feat...   Anthony Daniels Feb 13, 2006
Re: How do I change a Label Field of a feat...   Jim Fiddes Feb 13, 2006
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject How do I change a Label Field of a feature layer 
Author Anthony Daniels 
Date Feb 13, 2006 
Message I need to change the label field of a feature layer.

I am writing a procedure when a user clicks a radio button of the label field of their choice, the map will display the new label field. I have searched EDN without success (or my inexperience couldn't find an answer). Can someone help?

Thanks 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: How do I change a Label Field of a feature layer 
Author Jim Fiddes 
Date Feb 13, 2006 
Message To change the default label field you must use the IAnnotateLayerProperties.

The IAnnotateLayerProperties.Class represent the column you are labeling by.

Once you have set the information for the properties, you then add it to the collection (
IAnnotateLayerPropertiesCollection.Add(IAnnotateLayerProperties);).

The collection is equal to IGeoFeatureLayer.AnnotationProperties.

Sorry for being brief but this should get you going in the right direction. 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: How do I change a Label Field of a feature layer 
Author Anthony Daniels 
Date Feb 13, 2006 
Message How do I reference the column, by index or by name? Also how do I get the label to display on the map. I have seen a few examples using IAnnotateLayerPropertiesCollection, IAnnotateLayerProperties, ILabelEngineLayerProperties and BasicOverposterLayerProperties and have been working with code for days w/o success. Can you assist a little more. It is starting to drive me a little crazy.

Thanks 
 
I Have tried this:

    Private Sub ChangeLabel(ByVal LayerName As String, ByVal DisplayField As String)

        Dim tSym As TextSymbol = New TextSymbolClass
        Dim FLayer As IFeatureLayer = m_Featurelayer
        Dim GLayer As IGeoFeatureLayer = CType(FLayer, IGeoFeatureLayer)
        Dim iEProp As ILabelEngineLayerProperties = New LabelEngineLayerPropertiesClass
        Dim iAnnoProp As IAnnotateLayerPropertiesCollection
        Dim bProp As IBasicOverposterLayerProperties = New BasicOverposterLayerPropertiesClass

        GLayer.AnnotationProperties.Clear()
        iAnnoProp = GLayer.AnnotationProperties

        Dim font As IFontDisp = tSym.Font
        font.Bold = True
        font.Size = 40
        tSym.Font = font

        'Field to read in table
        GLayer.DisplayField = DisplayField

        bProp.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolygon

        iEProp.BasicOverposterProperties = CType(bProp, BasicOverposterLayerProperties)

        iEProp.Symbol = tSym

        GLayer.AnnotationProperties.Add(CType(iEProp, IAnnotateLayerProperties))
        GLayer.DisplayAnnotation = True

    End Sub

And This:

        Dim pGeoLayer As IGeoFeatureLayer = m_Featurelayer

        Dim pAnnoLayerPropsColl As IAnnotateLayerPropertiesCollection = pGeoLayer.AnnotationProperties

        Dim pAnnoLayerProps As IAnnotateLayerProperties
        pAnnoLayerPropsColl.Clear()

        Dim pBOLayerProps As IBasicOverposterLayerProperties
        pBOLayerProps = New BasicOverposterLayerProperties

        pBOLayerProps.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolygon
        pBOLayerProps.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerShape
        pBOLayerProps.FeatureWeight = esriBasicOverposterWeight.esriNoWeight
        pBOLayerProps.LabelWeight = esriBasicOverposterWeight.esriLowWeight

        Dim tSym As TextSymbol = New TextSymbolClass
        Dim font As IFontDisp = tSym.Font
        font.Bold = True
        font.Size = 40
        tSym.Font = font

        Dim aLELayerProps As ILabelEngineLayerProperties = New LabelEngineLayerProperties
        aLELayerProps.Expression = "[SDE.TAXLANDVIEW.LI_VALUE]"
        aLELayerProps.IsExpressionSimple = True
        aLELayerProps.Symbol = tSym
        aLELayerProps.BasicOverposterLayerProperties = pBOLayerProps

        Dim pSelField As String
        pSelField = """SDE.TAXLANDVIEW.LI_VALUE"""
        Dim pSelValue As String
        pSelValue = "'0'"
        Dim pSqlString As String
        pSqlString = pSelField & " <> " & pSelValue

        pAnnoLayerProps = aLELayerProps
        pAnnoLayerProps.Class = "Tax Value"
        pAnnoLayerProps.WhereClause = pSqlString

        pAnnoLayerPropsColl.Add(pAnnoLayerProps)

        pGeoLayer.DisplayAnnotation = True
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: How do I change a Label Field of a feature layer 
Author Jim Fiddes 
Date Feb 13, 2006 
Message In the example below a a snippet from one of my functions. The code sample should show you all the steps required to add a new Field to annotate by. After you have cleared the existing one. 
 
IGeoFeatureLayer _pGeoLayer = Featlyr as IGeoFeatureLayer;
IAnnotateLayerPropertiesCollection _pAnnoProps = _pGeoLayer.AnnotationProperties;
IBasicOverposterLayerProperties4 pBasic = new BasicOverposterLayerPropertiesClass();
pBasic.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerName;
pBasic.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolygon;
pBasic.PolygonPlacementMethod = esriOverposterPolygonPlacementMethod.esriMixedStrategy;			
ILabelEngineLayerProperties pLabelEngine = new LabelEngineLayerPropertiesClass();
pLabelEngine.BasicOverposterLayerProperties = pBasic as IBasicOverposterLayerProperties;
pLabelEngine.Expression = FieldLB.SelectedItem.ToString(); //selected layer column name example [Area]
pLabelEngine.Symbol = myTxtSym //text symbol which you will have to create;
IAnnotateLayerProperties _pAnnoLayerProps = pLabelEngine as IAnnotateLayerProperties;
_pAnnoLayerProps.Class = ClassTxt.Text;
_pAnnoProps.Add(_pAnnoLayerProps);
_pGeoLayer.DisplayAnnotation = true;
MapControl.ActiveView.Refresh();