Back to Devexpress

How to: Add a Legend Title

windowsforms-115946-controls-and-libraries-chart-control-examples-chart-elements-how-to-add-a-legend-title.md

latest1.6 KB
Original Source

How to: Add a Legend Title

  • Nov 13, 2018

To display the legend title, set the TitleBase.Visible property of the LegendBase.Title to true and specify the Title.Text of the LegendBase.Title. To customize the appearance of the title, you can change, for example, the AlignedTitle.DXAlignment, AlignedTitle.WordWrap and AlignedTitle.MaxLineCount properties to align the title to the left and divide it into several lines.

csharp
using System.Drawing;
// Specify legend title's text.
chart.Legend.Title.Text = "Area of countries";
// Show legend title.
chart.Legend.Title.Visible = true;
// Configure legend title appearance.
chart.Legend.Title.DXAlignment = DXStringAlignment.Near;
chart.Legend.Title.MaxLineCount = 3;
chart.Legend.Title.WordWrap = true;
vb
Imports System.Drawing
' Specify legend title's text.
chart.Legend.Title.Text = "Area of countries"
' Show legend title.
chart.Legend.Title.Visible = True
' Configure legend title appearance.
chart.Legend.Title.DXAlignment = DXStringAlignment.Near
chart.Legend.Title.MaxLineCount = 3
chart.Legend.Title.WordWrap = True