OneToManyLabels

Created:4/12/2002
Description:

The OneToManyLabels project is for labeling features based on attribute values accessible through one to many relationships. This functionality will be in the core software in a future release, but for now can be accomplished through this sample code. The code is a combination of C++ and VB as custom parsers currently can only be written in C++.

The code requires that a query on the related objects be done before labeling each feature, therefore performance will be slower than labeling features with attributes values in the feature class.


How to use:
  1. Double-click on the _Install.bat file in the code directory to register the tools. This batch file will register the two dlls (one from the C++ project and one from the VB project), and add the appropriate classes to the ESRI Annotation Expression Property Pages and ESRI Mx Annotation Expression Parsers categories.
  2. Start ArcMap and add layers to the map that participate in one to many relationships (the layer to label should be the Origin in the relationship).
  3. Access the Properties dialog for the layer and go to the Labels Tab. Click on the Expression button.
  4. Select the OneToMany tab on the Expression dialog. Select the relationship to use and the field(s) you want to label with. If you select two fields, then the strings will be separated by " - ". The resulting label will be stack with one line for each related record.
  5. Click OK to dismiss the EXpression dialog and the Properties dialog. Turn on labeling for the layer.

Application:
ArcMap

Requires: Layer participating in a one to many relationship as the Origin

Difficulty: Advanced


Visual Basic Visual C++
File Description
frmOneToManyProps.frm Form containing the controls for setting the labeling parameters.
OneToManyLabels.cls Class implementing the new expression engine for labeling.
OneToManyProps.cls Class implementing the new property page for one to many labeling.
OneToManyLabelsPrj.vbp Visual Basic project file.


Key CoClasses: LabelEngineLayerProperties, RelationshipClass
Key Interfaces: IAnnotateLayerProperties, IAnnotationExpressionEngine, IAnnotationExpressionParser, IAnnotationExpressionParser2, ICodedValueAttributes, IComPropertyPage, IObjectClass, IRelationshipClass, IRow
Key Members: IAnnotateLayerProperties::FeatureLayer, IAnnotationExpressionEngine::SetExpression, IAnnotationExpressionParser2::FindLabel, IComPropertyPage::SetObjects, IComPropertyPage::Show, IObjectClass::RelationshipClasses, IRelationshipClass::GetObjectsRelatedToObject, IRow::Value