Back to Devexpress

ScaleGridOptionsBase.AutoGrid Property

corelibraries-devexpress-dot-xtracharts-dot-scalegridoptionsbase.md

latest6.4 KB
Original Source

ScaleGridOptionsBase.AutoGrid Property

Gets or sets the value specifying whether the alignment, spacing and offset of grid lines and major tickmarks should be calculated automatically.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
[XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)]
public bool AutoGrid { get; set; }
vb
<XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)>
Public Property AutoGrid As Boolean

Property Value

TypeDescription
Boolean

true , if grid spacing is performed automatically; otherwise, false.

|

Remarks

The AutoGrid property is tightly interrelated with the ScaleGridOptionsBase.GridSpacing, ScaleGridOptionsBase.GridOffset and NumericScaleOptions.GridAlignment(DateTimeScaleOptions.GridAlignment) properties. Changing the value of one property affects the other. By default, the AutoGrid property is set to true and the grid line spacing is calculated automatically.

The following images demonstrate how the AutoGrid property works.

|

AutoGrid = true;

(auto) GridAlignment = Week;

(auto) GridSpacing = 1;

|

AutoGrid = false;

GridAlignment = Day;

GridSpacing = 3;

| | --- | --- | |

|

|

Note that if you need to define a custom grid interval, change the value of the ScaleGridOptionsBase.GridSpacing, ScaleGridOptionsBase.GridOffset or NumericScaleOptions.GridAlignment(DateTimeScaleOptions.GridAlignment) property. This automatically sets the AutoGrid property to false.

For more information, refer to Axis Scale Types.

Example

Use AxisBase.NumericScaleOptions, AxisBase.DateTimeScaleOptions, AxisBase.TimeSpanScaleOptions or AxisXBase.QualitativeScaleOptions to access the AutoGrid property.

csharp
NumericScaleOptions xAxisOptions = ((XYDiagram)chartControl1.Diagram).AxisX.NumericScaleOptions;
xAxisOptions.AutoGrid = true;
vb
Dim xAxisOptions As NumericScaleOptions = CType(chartControl1.Diagram, XYDiagram).AxisX.NumericScaleOptions
xAxisOptions.AutoGrid = True

The following code snippets (auto-collected from DevExpress Examples) contain references to the AutoGrid 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-charts-use-automatic-date-time-scale-modes-of-an-axis/CS/DateTimeAggregation/Form1.cs#L114

csharp
void SetAxisXGridAuto() {
    AxisX.DateTimeScaleOptions.AutoGrid = true;
    cbGridAlignment.SelectedIndex = 0;

winforms-charts-create-line-chart/CS/Series_LineChart/Form1.cs#L42

csharp
((XYDiagram)lineChart.Diagram).AxisY.InterlacedColor = Color.FromArgb(20, 60, 60, 60);
((XYDiagram)lineChart.Diagram).AxisX.NumericScaleOptions.AutoGrid = false;
((XYDiagram)lineChart.Diagram).AxisX.NumericScaleOptions.GridSpacing = 1;

winforms-charts-use-automatic-date-time-scale-modes-of-an-axis/VB/DateTimeAggregation/Form1.vb#L101

vb
Private Sub SetAxisXGridAuto()
    AxisX.DateTimeScaleOptions.AutoGrid = True
    cbGridAlignment.SelectedIndex = 0

winforms-charts-create-line-chart/VB/Series_LineChart/Form1.vb#L39

vb
CType(lineChart.Diagram, XYDiagram).AxisY.InterlacedColor = Color.FromArgb(20, 60, 60, 60)
CType(lineChart.Diagram, XYDiagram).AxisX.NumericScaleOptions.AutoGrid = False
CType(lineChart.Diagram, XYDiagram).AxisX.NumericScaleOptions.GridSpacing = 1

See Also

Grid Lines, Tickmarks and Interlacing

ScaleGridOptionsBase Class

ScaleGridOptionsBase Members

DevExpress.XtraCharts Namespace