Back to Devexpress

Adding Legends

windowsforms-115948-controls-and-libraries-chart-control-legends-adding-legends.md

latest3.0 KB
Original Source

Adding Legends

  • Apr 25, 2025

At Design Time

You can add a new legend to a chart at design time as follows:

  1. Select the chart. In the Properties window, locate the ChartControl.Legends property and click the ellipsis button. In the editor, click Add.

  2. Use the Legend.DockTarget property to dock the legend to the required pane or chart control.

  3. Position the legend using LegendBase.AlignmentVertical and LegendBase.AlignmentHorizontal properties.

  4. Assign the legend to a series, indicator, constant line or strip using the SeriesBase.Legend, Indicator.Legend, ConstantLine.Legend or Strip.Legend property respectively.

The following image shows the result:

Note

The additional legend will not be displayed at runtime until it is assigned to a series, indicator, constant line, or strip. At design time, an empty legend will be labeled with Empty Legend text.

In Code

The following help topic describes how to add additional legends at runtime: How to: Add an Additional Legend to a Chart.

Example: Add an Additional Legend to a Chart

View Example

Example: Show a Chart Legend with Markers in a Separate Control

This example shows a ChartControl legend in a GridControl.

View Example