This document is archived and information here might be outdated.  Recommended version.


ILegendItem Interface (ArcObjects .NET 10.5 SDK)
ArcObjects Library Reference (Carto)  

ILegendItem Interface

Provides access to members that control how a layer appears in a legend. Can be stored in a style. Note: the ILegendItem interface has been superseded byILegendItem3. Please consider using the more recent version.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Members

Description
Read-only property CanDisplay Indicates if the style is compatible with the specified layer.
Read/write property Columns Number of columns in the legend item.
Method CreateGraphics Rebuilds the list of graphics. Call whenever the associated layer changes.
Read-only property Graphics List of graphics that represent the legend item. Must call CreateGraphics first.
Read/write property GroupIndex Zero-based index of the legend group shown by this item. Use -1 to show all legend groups using this item.
Read/write property HeadingSymbol Text symbol used to draw the heading.
Read-only property Height Height of the item in points. Must call CreateGraphics first.
Read/write property KeepTogether Indicates if classes must appear in a single column or whether they can be split across multiple columns.
Read/write property Layer Associated layer.
Read/write property LayerNameSymbol Text symbol used to draw the layer name.
Read/write property LegendClassFormat Default formatting information for the legend classes. Renderer may override.
Read-only property Name Name of the style.
Read/write property NewColumn Indicates if the item starts a new column in the legend.
Read/write property ShowDescriptions Indicates if descriptions are visible.
Read/write property ShowHeading Indicates if heading is visibile.
Read/write property ShowLabels Indicates if labels are visible.
Read/write property ShowLayerName Indicates if layer name is visibile.
Read-only property Width Width of the item in points. Must call CreateGraphics first.

CoClasses that implement ILegendItem

CoClasses and Classes Description
HorizontalBarLegendItem Horizontal bar legend item.
HorizontalLegendItem Horizontal legend item.
NestedLegendItem Nested legend item.
VerticalLegendItem Vertical legend item.

Remarks

The Legend can be seen as a collection of map layers each layer being represented by a LegendItem.
The ILegendItem interface controls all the properties of a legend item:

CanDisplay will be true if the type of the LegendItem is compatible with the rendering of the layer. NestedLegendItem for instance, cannot be used by all renderers.

The Layer property returns the layer this LegendItem is associated with

Columns is the number of columns it should span. Height and Width control the size of the legend item.

ILegendItem also gives access to the graphic elements used to draw the legend item - Graphics property - to the symbols specific to this legend item - HeadingSymbol, LayerNameSymbol - and to the legend items LegendClassFormat object.

NewColumn controls whether the LegendItem should be displayed starting a new column. KeepTogether indicates if it can be split over different columns. A number of properties control whether the label, description, heading, and layer name should be displayed.

Horizontal and Vertical legend items use the esriLegendItemArrangement enumeration which can be set with IHorizontalLegendItem::Arrangement and IVerticalLegendItem::Arrangement to specify the position of the label, patch, and description. The default is esriPatchLabelDescription, which translates to the patch on the far left, label to the right of the patch, then the description, if available, on the far right.
There are currently four types of legend items: HorizontalLegendItem, VerticalLegendItem, HorizontalBarLegendItem, and NestedLegendItem with corresponding interfaces.

Horizontal legend items are the default and most commonly used class of legend items.