IFeatureLayer.DisplayField incorrect

2374
2
04-16-2015 08:00 AM
Highlighted
New Contributor II

Hi,

I'm using ArcObjects in C# .NET to create an ArcMap add-in for ArcGIS 10.2.1. I add the attached shape file as a layer to a document in ArcMap, enable Labels and set its Display Field to different fields, e.g. DETALJTYP. But the only field name that I can get programmatically from IFeatureLayer.DisplayField is EXTERNID, and I can't see why? It works fine with other layers. Any idea what's going on?

Regards,

Andreas Ekstrand

Reply
0 Kudos
2 Replies
Highlighted
Regular Contributor II

I may not be understanding you correctly, but the only field that should be returned from IFeatureLayer::DisplayField would be the name of the field that is currently set as the DisplayField for the layer. In your case you data would set the "EXTERNID" by default until you change it.

I wrote a quick sample to check against your data and everything works fine for me. You can look at it below to compare it to what you're doing differently.

2015-04-16_0907.png

Reply
0 Kudos
Highlighted
New Contributor II

Sorry, I managed to get DisplayField and the ILabelEngineLayerProperties.Expression mixed up, they were similar in the layer properties and so far they must have coincided so I didn't notice. Thanks!

Reply
0 Kudos