Back to Devexpress

TitleBase.TextColor Property

corelibraries-devexpress-dot-xtracharts-dot-titlebase-b412523f.md

latest9.5 KB
Original Source

TitleBase.TextColor Property

Gets or sets a title’s text color.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
[XtraChartsLocalizableCategory(XtraChartsCategory.Appearance)]
public Color TextColor { get; set; }
vb
<XtraChartsLocalizableCategory(XtraChartsCategory.Appearance)>
Public Property TextColor As Color

Property Value

TypeDescription
Color

A Color structure which specifies the color of a title’s text.

|

Example

This example demonstrates how to access an axis title at runtime.

Cast your diagram object to the required diagram type to access its axes. Then, you can access the Axis2D.Title property.

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 AxisTitle {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e) {
        // ...
            // Cast the chart's diagram to the XYDiagram type, to access its axes.
            XYDiagram diagram = chartControl1.Diagram as XYDiagram;

            // Customize the appearance of the X-axis title.
            diagram.AxisX.Title.Visibility = DevExpress.Utils.DefaultBoolean.True;
            diagram.AxisX.Title.Alignment = StringAlignment.Center;
            diagram.AxisX.Title.Text = "<i>X-axis</i> <color=violet>Title</color>";
            diagram.AxisX.Title.TextColor = Color.Red;
            diagram.AxisX.Title.EnableAntialiasing = DevExpress.Utils.DefaultBoolean.True;
            diagram.AxisX.Title.DXFont = new DXFont("Tahoma", 14, DXFontStyle.Bold);

            // Customize the appearance of the Y-axis title.
            diagram.AxisY.Title.Visibility = DevExpress.Utils.DefaultBoolean.True;
            diagram.AxisY.Title.Alignment = StringAlignment.Center;
            diagram.AxisY.Title.Text = "Y-axis Title";
            diagram.AxisY.Title.TextColor = Color.Blue;
            diagram.AxisY.Title.EnableAntialiasing = DevExpress.Utils.DefaultBoolean.True;
            diagram.AxisY.Title.DXFont = new DXFont("Tahoma", 14, DXFontStyle.Bold);

            // Add the chart to the form.
            chartControl1.Dock = DockStyle.Fill;
            this.Controls.Add(chartControl1);
        }
    }
}
vb
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports DevExpress.Drawing
Imports DevExpress.XtraCharts

Namespace AxisTitle

    Public Partial Class Form1
        Inherits Form
        ' ...
            ' Hide the legend (if necessary).
            chartControl1.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False
            ' Cast the chart's diagram to the XYDiagram type, to access its axes.
            Dim diagram As XYDiagram = TryCast(chartControl1.Diagram, XYDiagram)
            ' Customize the appearance of the X-axis title.
            diagram.AxisX.Title.Visibility = DevExpress.Utils.DefaultBoolean.True
            diagram.AxisX.Title.Alignment = StringAlignment.Center
            diagram.AxisX.Title.Text = "<i>X-axis</i> <color=violet>Title</color>"
            diagram.AxisX.Title.TextColor = Color.Red
            diagram.AxisX.Title.EnableAntialiasing = DevExpress.Utils.DefaultBoolean.True
            diagram.AxisX.Title.DXFont = New DXFont("Tahoma", 14, DXFontStyle.Bold)
            ' Customize the appearance of the Y-axis title.
            diagram.AxisY.Title.Visibility = DevExpress.Utils.DefaultBoolean.True
            diagram.AxisY.Title.Alignment = StringAlignment.Center
            diagram.AxisY.Title.Text = "Y-axis Title"
            diagram.AxisY.Title.TextColor = Color.Blue
            diagram.AxisY.Title.EnableAntialiasing = DevExpress.Utils.DefaultBoolean.True
            diagram.AxisY.Title.DXFont = New DXFont("Tahoma", 14, DXFontStyle.Bold)
            ' Add the chart to the form.
            chartControl1.Dock = DockStyle.Fill
            Me.Controls.Add(chartControl1)
        End Sub
    End Class
End Namespace

The following code snippets (auto-collected from DevExpress Examples) contain references to the TextColor property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-chart-create-and-customize-an-axis-title/CS/AxisTitle/Form1.cs#L37

csharp
diagram.AxisX.Title.Text = "<i>X-axis</i> <color=violet>Title</color>";
diagram.AxisX.Title.TextColor = Color.Red;
diagram.AxisX.Title.EnableAntialiasing = DevExpress.Utils.DefaultBoolean.True;

winforms-dashboard-custom-properties/CS/WinForms-Dashboard-Custom-Properties/Modules/ConstantLineUserValueModule.cs#L100

csharp
line.Title.Text = "Value: " + moduleData.Value.ToString();
    line.Title.TextColor = line.Color;
}

winforms-chart-create-and-customize-chart-titles/CS/Form1.cs#L36

csharp
chartTitle1.DXFont = new DXFont("Tahoma", 14, DXFontStyle.Bold);
chartTitle1.TextColor = Color.Red;
chartTitle1.Indent = 10;

wpf-dashboard-custom-properties/CS/Wpf-Dashboard-Custom-Properties/Modules/ChartItemModule/ChartOptions/ConstantLine.cs#L98

csharp
line.Title.Text = "Value: " + moduleData.Value;
    line.Title.TextColor = line.Color;
}

winforms-chart-create-and-customize-an-axis-title/VB/AxisTitle/Form1.vb#L36

vb
diagram.AxisX.Title.Text = "<i>X-axis</i> <color=violet>Title</color>"
diagram.AxisX.Title.TextColor = Color.Red
diagram.AxisX.Title.EnableAntialiasing = DevExpress.Utils.DefaultBoolean.True

winforms-dashboard-custom-properties/VB/WinForms-Dashboard-Custom-Properties/Modules/ConstantLineUserValueModule.vb#L106

vb
line.Title.Text = "Value: " & moduleData.Value.ToString()
    line.Title.TextColor = line.Color
End If

winforms-chart-create-and-customize-a-constant-line/VB/ConstLines/Form1.vb#L45

vb
constantLine1.Title.Text = "Constant Line Title"
constantLine1.Title.TextColor = Color.Red
constantLine1.Title.EnableAntialiasing = DevExpress.Utils.DefaultBoolean.False

winforms-chart-create-and-customize-chart-titles/VB/Form1.vb#L34

vb
chartTitle1.DXFont = New DXFont("Tahoma", 14, DXFontStyle.Bold)
chartTitle1.TextColor = Color.Red
chartTitle1.Indent = 10

wpf-dashboard-custom-properties/VB/Wpf-Dashboard-Custom-Properties/Modules/ChartItemModule/ChartOptions/ConstantLine.vb#L122

vb
line.Title.Text = "Value: " & moduleData.Value
    line.Title.TextColor = line.Color
End If

See Also

TitleBase Class

TitleBase Members

DevExpress.XtraCharts Namespace