Back to Devexpress

Pane Title

windowsforms-120591-controls-and-libraries-chart-control-panes-pane-title.md

latest6.0 KB
Original Source

Pane Title

  • Oct 23, 2024
  • 3 minutes to read

You can show a title above the pane to distinguish between multiple panes. End users can use the expand button next to the title to hide or show panes.

This document explains how to:

Add a Pane Title

Each pane can have one title. To display the title, set its Visibility property to True. The title is shown with a button that allows you to collapse and expand a pane if the XYDiagramPaneBase.RuntimeCollapse (or XYDiagram2D.RuntimePaneCollapse) option is enabled. If an end user collapses a pane, other panes’ sizes are recalculated to occupy all the available space. Set RuntimeCollapse to false to hide the title expand button and prevent end users from collapsing panes.

To specify the title’s content, use the Text property. Its default value is the pane’s Name property value.

Note

The Chart Control can hide its elements if there is insufficient space to display them. Elements are hidden in the following order:

  1. Legends
  2. Axis Titles
  3. Series Titles
  4. Pane Titles
  5. Axes
  6. Chart Title
  7. Breadcrumbs

To make the Chart Control always display its elements, disable the ChartControl.AutoLayout property.

Add a Title at Design Time

You can configure a pane title’s options in the Properties window:

Add a Title in Code

The following code specifies a pane’s title text and visibility:

csharp
XYDiagramPane pane = diagram.Panes["Temperature Pane"];
if(pane != null) {
    pane.Title.Text = "Temperature";
    pane.Title.Visibility = DefaultBoolean.True;
}
vb
Dim pane As XYDiagramPane = diagram.Panes("Temperature Pane")
If (Not (pane) Is Nothing) Then
    pane.Title.Text = "Temperature"
    pane.Title.Visibility = DefaultBoolean.True
End If

The code above uses the following API members:

MemberDescription
XYDiagramPaneBase.TitleReturns the pane title settings.
Title.TextGets or sets title content.
PaneTitle.VisibilitySpecifies whether the title is visible.

Align a Pane Title

You can align a pane title to the pane’s top edge and configure indents between the title and other chart elements.

The following code shows how to customize the alignment and margins:

csharp
pane.Title.Alignment = StringAlignment.Far;
pane.Title.Margins.Left = 0;
pane.Title.Margins.Top = 10;
pane.Title.Margins.Right = 0;
pane.Title.Margins.Bottom = 10;
vb
pane.Title.Alignment = StringAlignment.Far
pane.Title.Margins.Left = 0
pane.Title.Margins.Top = 10
pane.Title.Margins.Right = 0
pane.Title.Margins.Bottom = 10

Use the following API members to align pane titles:

MemberDescription
PaneTitle.DXAlignmentSpecifies the title’s alignment.
PaneTitle.MarginsSpecifies the title’s outer indents.
RectangleIndents.LeftGets or sets the title’s left margin.
RectangleIndents.TopGets or sets the title’s upper margin.
RectangleIndents.RightSpecifies the title’s right margin.
RectangleIndents.BottomGets or sets the title’s lower margin.

Customize a Title’s Text Appearance

You can use the TitleBase.DXFont property to configure font parameters, and the TitleBase.TextColor property to change the title’s color.

The following sample demonstrates how to change a title’s font and color:

csharp
using System.Drawing;
using DevExpress.Drawing;
// ...
pane.Title.DXFont = new DXFont("Tahoma", 14, DXFontStyle.Bold);
pane.Title.TextColor = Color.Gray;
vb
Imports System.Drawing
Imports DevExpress.Drawing
' ...
pane.Title.DXFont = New DXFont("Tahoma", 14, DXFontStyle.Bold)
pane.Title.TextColor = Color.Gray

The code above uses the following properties:

PropertyDescription
TitleBase.DXFontSpecifies the title’s font.
TitleBase.TextColorDefines the title’s text color.