How to: Enable Word Wrapping for Chart Titles

  • 2 minutes to read

This example demonstrates how word-wrapping can be enabled for chart titles at runtime. In addition, you can determine the maximum number of lines in which a title is allowed to wrap.

// Create a title and add it to the chart's collection.
ChartTitle chartTitle1 = new ChartTitle();
ChartControl1.Titles.Add(chartTitle1);
chartTitle1.Text = "Just a Very Lengthy Title for Such a Small Chart";

// Enable word-wrapping for the title,
// and define a limit for its lines.
chartTitle1.WordWrap = true;
chartTitle1.MaxLineCount = 2;

The result is shown in the following image.

ChartTitles_2c

The title is cut by the ellipsis, since it's text exceeds the defined two lines. If required, you can increase the AlignedTitle.MaxLineCount property's value, so the entire text will fit. Note that in this case, the chart's diagram, in turn, will be shrunk.

ChartTitles_2b

TIP

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E1375.

See Also