Each Axis (in particular, an axis of the AxisX or AxisY type) can hold a collection of constant lines which can be accessed via the Axis2D.ConstantLines property and is represented by the ConstantLineCollection class. The properties and methods exposed by the ConstantLineCollection class can be used to perform common collection operations such as adding new or deleting existing items. Each collection item is represented by a ConstantLine object. Individual constant lines can be accessed either using indexer notation or by their names using specific methods of the collection.
For more information, refer to Constant Lines.

Example
This example demonstrates how a constant line can be created and customized at runtime.
Since constant lines belong to a diagram's axis, it's first required to cast your Diagram object to the appropriate diagram's type. After that, it's possible to access axes and manage their constant lines collection.
C# |
XYDiagram diagram = (XYDiagram)chartControl1.Diagram;
ConstantLine constantLine1 = new ConstantLine("Constant Line 1");
diagram.AxisY.ConstantLines.Add(constantLine1);
constantLine1.AxisValue = 7;
constantLine1.Visible = true;
constantLine1.ShowInLegend = true;
constantLine1.LegendText = "Some Threshold";
constantLine1.ShowBehind = false;
constantLine1.Title.Visible = true;
constantLine1.Title.Text = "Constant Line Title";
constantLine1.Title.TextColor = Color.Red;
constantLine1.Title.Antialiasing = false;
constantLine1.Title.Font = new Font("Tahoma", 14, FontStyle.Bold);
constantLine1.Title.ShowBelowLine = true;
constantLine1.Title.Alignment = ConstantLineTitleAlignment.Far;
constantLine1.Color = Color.Red;
constantLine1.LineStyle.DashStyle = DashStyle.Dash;
constantLine1.LineStyle.Thickness = 2;
|
VB |
Dim diagram As XYDiagram = CType(chartControl1.Diagram, XYDiagram)
Dim constantLine1 As New ConstantLine("Constant Line 1")
diagram.AxisY.ConstantLines.Add(constantLine1)
constantLine1.AxisValue = 7
constantLine1.Visible = True
constantLine1.ShowInLegend = True
constantLine1.LegendText = "Some Threshold"
constantLine1.ShowBehind = False
constantLine1.Title.Visible = True
constantLine1.Title.Text = "Constant Line Title"
constantLine1.Title.TextColor = Color.Red
constantLine1.Title.Antialiasing = False
constantLine1.Title.Font = New Font("Tahoma", 14, FontStyle.Bold)
constantLine1.Title.ShowBelowLine = True
constantLine1.Title.Alignment = ConstantLineTitleAlignment.Far
constantLine1.Color = Color.Red
constantLine1.LineStyle.DashStyle = DashStyle.Dash
constantLine1.LineStyle.Thickness = 2
|
System.Object
System.Collections.CollectionBase
ChartCollectionBase
ChartElementNamedCollection
ConstantLineCollection