Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Enable Word Wrapping for Chart Titles

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 https://supportcenter.devexpress.com/ticket/details/e1375/chart-for-winforms-how-to-create-and-customize-chart-titles.

See Also