GridLines Class

Defines the settings of grid lines.

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v20.1.dll

Declaration

public abstract class GridLines :
    ChartElement
Public MustInherit Class GridLines
    Inherits ChartElement

Returned By

The AxisBase.GridLines property returns an instance of GridLines.

Remarks

The GridLines class serves as a base for the GridLinesX and GridLinesY classes and declares properties that define the common settings of different grid lines which can displayed within a chart control's diagram.

The main settings exposed via the properties of the GridLines class allow you to specify the color, line style and visibility of both major grid lines (GridLines.Color, GridLines.LineStyle, GridLines.Visible) and minor grid lines (GridLines.MinorColor, GridLines.MinorLineStyle, GridLines.MinorVisible).

For more information, refer to Grid Lines, Tickmarks and Interlacing.

Examples

This example demonstrates how the grid lines and tickmarks of an axis can be customized at runtime.

To access an axis, you should cast your chart's diagram object to the required diagram type. Then, use the Axis2D.Tickmarks and AxisBase.GridLines properties to access the corresponding elements. To define the number of minor tickmarks (grid lines), use the AxisBase.MinorCount property.

// Cast the chart's diagram to the XYDiagram type, to access its axes.
XYDiagram diagram = (XYDiagram)chartControl1.Diagram;

// Customize the appearance of the axes' tickmarks.
diagram.AxisX.Tickmarks.CrossAxis = true;
diagram.AxisX.Tickmarks.Length = 5;
diagram.AxisX.Tickmarks.Thickness = 2;

diagram.AxisY.Tickmarks.Visible = false;
diagram.AxisY.Tickmarks.MinorVisible = false;

diagram.AxisX.Tickmarks.MinorLength = 3;
diagram.AxisX.Tickmarks.MinorThickness = 1;

diagram.AxisX.MinorCount = 2;
diagram.AxisY.MinorCount = 4;

// Customize the appearance of the axes' grid lines.
diagram.AxisX.GridLines.Visible = false;
diagram.AxisX.GridLines.MinorVisible = false;

diagram.AxisY.GridLines.Visible = true;
diagram.AxisY.GridLines.MinorVisible = true;

diagram.AxisY.GridLines.Color = Color.Red;
diagram.AxisY.GridLines.LineStyle.DashStyle = DashStyle.Solid;
diagram.AxisY.GridLines.LineStyle.Thickness = 2;

diagram.AxisY.GridLines.MinorColor = Color.Blue;
diagram.AxisY.GridLines.MinorLineStyle.DashStyle = DashStyle.Dash;
diagram.AxisY.GridLines.MinorLineStyle.Thickness = 1;
See Also