Back to Devexpress

ChartControl.Titles Property

windowsforms-devexpress-dot-xtracharts-dot-chartcontrol-3d7d161f.md

latest5.5 KB
Original Source

ChartControl.Titles Property

Gets the collection of chart titles.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.UI.dll

NuGet Package : DevExpress.Win.Charts

Declaration

csharp
public ChartTitleCollection Titles { get; }
vb
Public ReadOnly Property Titles As ChartTitleCollection

Property Value

TypeDescription
ChartTitleCollection

A ChartTitleCollection object that represents the collection of chart titles.

|

Remarks

The Titles property provides access to a collection in which objects representing chart titles are stored (if any). Chart title objects can be manipulated (added or removed) via methods and properties provided by the ChartTitleCollection object. Individual chart titles (objects of the ChartTitle type) can be accessed via the Titles property using indexer notation.

For more information, refer to Chart Titles.

Example

This example demonstrates how to create and customize chart titles at runtime.

View Example: How to Create and Customize an Axis Title

cs
using System;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.Drawing;
using DevExpress.XtraCharts;

namespace WindowsApplication25 {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e) {
            // Create chart titles.
            ChartTitle chartTitle1 = new ChartTitle();
            ChartTitle chartTitle2 = new ChartTitle();

            // Define the text for the titles.
            chartTitle1.Text = "<i>Basic</i> <b>HTML</b> <u>is</u> <color=blue>supported</color>.";
            chartTitle2.Text = "The capability to word-wrap is available for chart titles.";

            chartTitle2.WordWrap = true;
            chartTitle2.MaxLineCount = 2;

            // Define the alignment of the titles.
            chartTitle1.Alignment = StringAlignment.Center;
            chartTitle2.Alignment = StringAlignment.Near;

            // Place the titles where it's required.
            chartTitle1.Dock = ChartTitleDockStyle.Top;
            chartTitle2.Dock = ChartTitleDockStyle.Bottom;

            // Customize a title's appearance.
            chartTitle1.EnableAntialiasing = DevExpress.Utils.DefaultBoolean.True;
            chartTitle1.DXFont = new DXFont("Tahoma", 14, DXFontStyle.Bold);
            chartTitle1.TextColor = Color.Red;
            chartTitle1.Indent = 10;

            // Add the titles to the chart.
            chartControl1.Titles.AddRange(new ChartTitle[] {
                chartTitle1,
                chartTitle2});
        }
    }
}
vb
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports DevExpress.Drawing
Imports DevExpress.XtraCharts

Namespace WindowsApplication25

    Public Partial Class Form1
        Inherits Form

        Public Sub New()
            InitializeComponent()
        End Sub

        Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
            ' Create chart titles.
            Dim chartTitle1 As ChartTitle = New ChartTitle()
            Dim chartTitle2 As ChartTitle = New ChartTitle()
            ' Define the text for the titles.
            chartTitle1.Text = "<i>Basic</i> <b>HTML</b> <u>is</u> <color=blue>supported</color>."
            chartTitle2.Text = "The capability to word-wrap is available for chart titles."
            chartTitle2.WordWrap = True
            chartTitle2.MaxLineCount = 2
            ' Define the alignment of the titles.
            chartTitle1.Alignment = StringAlignment.Center
            chartTitle2.Alignment = StringAlignment.Near
            ' Place the titles where it's required.
            chartTitle1.Dock = ChartTitleDockStyle.Top
            chartTitle2.Dock = ChartTitleDockStyle.Bottom
            ' Customize a title's appearance.
            chartTitle1.EnableAntialiasing = DevExpress.Utils.DefaultBoolean.True
            chartTitle1.DXFont = New DXFont("Tahoma", 14, DXFontStyle.Bold)
            chartTitle1.TextColor = Color.Red
            chartTitle1.Indent = 10
            ' Add the titles to the chart.
            chartControl1.Titles.AddRange(New ChartTitle() {chartTitle1, chartTitle2})
        End Sub
    End Class
End Namespace

See Also

Chart Titles

ChartControl Class

ChartControl Members

DevExpress.XtraCharts Namespace