Select to view content in your preferred language

How do I label features programmatically using arcobjects?

3992
2
04-26-2016 10:06 AM
AmritKumar1
Deactivated User

I want to label the features of feature layers in my TOC. This has to be using the CommandBar and CommandItem. How should I go about it? Some heads up will be appreciated

Thanks

0 Kudos
2 Replies
FreddieGibson
Honored Contributor

If you already have a tool on a toolbar that displays the labels you would use the following code to find the command and just call ICommandItem.Execute to execute the command.

desktop.arcgis.com/en/arcobjects/latest/net/webframe.htm#2ffb7cab-820e-4581-970f-49c887108f87.htm

I don't recall any out-of-the-box commands that display labels. In my code I display the labels using IGeoFeatureLayer.DisplayAnnotation. This is mentioned starting on the following page.

Working with labels and annotation (ArcObjects)

http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/#/Working_with_labels_and_annotati...

AmritKumar1
Deactivated User

Thank you for the quick response @Freddie. I was able to complete the action using the DisplayAnnotation method, but I wanted to follow the commandItem methods for this task.

I will try out the code in the link you mentioned. Thanks again!

0 Kudos