Xceed Chart for WinForms v4.4 Documentation
Axis Grid Lines

Welcome to Xceed Chart for WinForms v4.4 > User Guide > Axes > Axis Grid Lines

The grid lines of the axes are displayed on the chart walls. As with ticks, there are major and minor grid lines. Their position is determined by the position of the corresponding tick they represent. The user can show the axis grid lines on more than one chart wall.

Controlling the Display of Grid Lines on Chart Walls

You can control the walls on which grid lines are displayed with the SetMajorShowAtWall and SetMinorShowAtWall methods of the Axis object. For vertical axes, these methods accept only the four vertical walls. For horizontal axes, these methods accept the back, the floor, and the front wall. For the Depth axis, the same methods will accept the left wall, the chart floor, and the right wall. You can also query whether a line is displayed on a particular wall with the GetMajorShowAtWall and GetMinorShowAtWall methods of the Axis object. 

The following example disables displaying the major grid lines of the left axis on the back wall (by default the grid lines of the left axis are also displayed on the left wall) and also queries whether SecondaryY axis displays its grid lines on the left wall.

VB.NET  

Dim chart As Chart = CType(chartControl1.Charts(0), Chart)

chart.Axis(StandardAxis.PrimaryY).SetMajorShowAtWall(ChartWallType.Back, False)

Dim bDisplay As Boolean =   Chart.Axis(StandardAxis.SeconaryY).GetMajorShowAtWall(ChartWallType.Left)

C#  

Chart chart = (Chart)nChartControl1.Charts[0];

chart.Axis(StandardAxis.PrimaryY).SetMajorShowAtWall(ChartWallType.Back, false);

bool bDisplay = Chart.Axis(StandardAxis.SeconaryY).GetMajorShowAtWall(ChartWallType.Left);

Controlling the Appearance of Grid Lines

Grid lines are displayed as simple lines. The user can obtain the LineProperties objects controlling the appearance of the major and minor grid lines with the MajorGridLine and MinorGridLine properties. 

The following code will display the PrimaryY major grid lines with in red, while the minor grid lines will be displayed in blue.

VB.NET  

Dim axis As Axis =   Chart.Axis(StandardAxis.PrimaryY)

axis.MajorGridLine.Color = Color.Red

axis.MinorGridLine.Color = Color.Blue

C#  

Axis axis = Chart.Axis(StandardAxis.PrimaryY);

axis.MajorGridLine.Color = Color.Red;

axis.MinorGridLine.Color = Color.Blue;

Related Examples

Windows Forms: Axes\General\Gridlines

See Also

Axis