All Controls


Add a New Subcaption

The page describes how to add subcaptions to a chart. The collection of captions is of the following type:

This collection can hold more than one caption, and these captions can be placed at different locations. A single caption of the charts is of the following type:

The first step is to include the necessary namespaces for the controls and add a new chart.

Add a Subcaption

Below, we will add subcaptions to an Individuals chart (named indChart in the examples below). The process is similar for the other charts:

[Visual Basic]
' Create a new caption and add it to the chart
Dim ccLeft As New ChartCaption("Units=mL");
indChart.Captions.Add(ccLeft)
' Set the placement and font of the new caption
ccLeft.HorizontalPlacement = HorizontalCaptionPlacement.Left
ccLeft.VerticalPlacement = VerticalCaptionPlacement.Top
ccLeft.Font = new Font("Arial", 8)

' Create a second new caption and add it to the chart
Dim ccCenter As New ChartCaption("Measurements")
indChart.Captions.Add(ccCenter)
' Set the placement and font of the new caption
ccCenter.HorizontalPlacement = HorizontalCaptionPlacement.Center
ccCenter.VerticalPlacement = VerticalCaptionPlacement.Bottom
ccCenter.Font = new Font("Arial", 8)

[Visual C#]
// Create a new caption and add it to the chart
ChartCaption ccLeft = new ChartCaption("Units=mL");
indChart.Captions.Add(ccLeft);
// Set the placement and font of the new caption
ccLeft.HorizontalPlacement = HorizontalCaptionPlacement.Left;
ccLeft.VerticalPlacement = VerticalCaptionPlacement.Top;
ccLeft.Font = new Font("Arial", 8);

// Create a second new caption and add it to the chart
ChartCaption ccCenter = new ChartCaption("Measurements");
indChart.Captions.Add(ccCenter)
// Set the placement and font of the new caption
ccCenter.HorizontalPlacement = HorizontalCaptionPlacement.Center;
ccCenter.VerticalPlacement = VerticalCaptionPlacement.Bottom;
ccCenter.Font = new Font("Arial", 8);

The resulting chart should look similar to the following:

Individuals chart with subcaptions