Switch on labels

Here is a small piece of code, which can be used to switch on labels. Why do I feel it to be on the post? ¬†Well, due to its simplicity. Have a look: –

Public Sub SwitchOnLabels(pFeatLayer As IFeatureLayer, DisplayField As String)

Dim pGFLayer As IGeoFeatureLayer
Set pGFLayer = pFeatLayer

Dim pLabelEngine As ILabelEngineLayerProperties
Set pLabelEngine = New LabelEngineLayerProperties
Dim pAnnoLayerProps As IAnnotateLayerProperties

Set pAnnoLayerProps = pLabelEngine
Set pAnnoLayerProps.FeatureLayer = pGFLayer

Dim exp As String
exp = "[" & DisplayField & "]"
pLabelEngine.Expression = exp
pLabelEngine.IsExpressionSimple = True
pGFLayer.AnnotationProperties.Clear
pGFLayer.AnnotationProperties.Add pLabelEngine
pGFLayer.DisplayAnnotation = True
End Sub

Advertisements

About Paritosh Gupta

I am an M.Tech from IIT Roorkee and MBA from IIM Lucknow India. I am having more than 16 years of experience in design, development, Integration and implementation of Geographical Information System for various applications in Utilities, Watershed Management and Land records domains
This entry was posted in ArcObjects with Visual Basic. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s