# Displaying Grid Lines on a Sheet

Learn how to customize grid lines in your spreadsheets with ease and efficiency. Find out how to change the color, width, and style of grid lines for a visually appealing presentation.

## Content

By default sheets display grid lines. You can set the color, the width, and the style of grid lines. In the following figure, the horizontal grid lines are flat and red, and the vertical grid lines are flat and green.
![Spread control with red grid lines](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/gridlinecolor.png)
You can choose to display the grid lines as three-dimensional lines, with a highlight and shadow color. If you do so, set the highlight and shadow color to create the effect you want. For basic customization of grid lines, use the following properties of the [GridLine](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.GridLine.html) class.

* [Color](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.GridLine.Color.html) \- the color of the grid line
* [HighlightColor](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.GridLine.HighlightColor.html) \- the highlight color for three\-dimensional grid lines
* [ShadowColor](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.GridLine.ShadowColor.html) \- the shadow color for three\-dimensional grid lines
* [Type](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.GridLine.Type.html) \- the type of grid line
* [Width](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.GridLine.Width.html) \- the width in pixels of the grid line

The **Color** property is for flat lines, and the **HighlightColor** and **ShadowColor** property are for the other types of lines.
You can hide the grid line in a particular direction by setting the **Type** property of grid line to "None". Refer to the following line of code to hide horizontal grid line.

```csharp
fpSpread1.ActiveSheet.HorizontalGridLine = new FarPoint.Win.Spread.GridLine(FarPoint.Win.Spread.GridLineType.None);
```

```vbnet
fpSpread1.ActiveSheet.HorizontalGridLine = New FarPoint.Win.Spread.GridLine(FarPoint.Win.Spread.GridLineType.None)
```

To customize other properties, create a new [GridLine](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.GridLine.html) object (rather than changing a property on the existing object).
For more details on how to work with the grid lines in code, refer to the examples below, the [GridLine](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.GridLine.html) class, and [HorizontalGridLine](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.HorizontalGridLine.html) property or [VerticalGridLine](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.VerticalGridLine.html) property of the [SheetView](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.html) class.

> !type=note
> **Note:**
>
> * You can display lines around individual cells by setting cell borders. For more information, refer to [Creating and Customizing Cell Borders](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-setappearance/spwin-appearcell/spwin-cellborder).
> * For information on setting the grid lines in a header, refer to [Customizing the Header Grid Lines](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-header/spwin-appearheader/spwin-headergridlines).

## Using the Properties Window

1. At design time, in the **Properties** window, select the Spread component.
2. Select the **Sheets** property
3. Click the button to display the **SheetView Collection Editor**.
4. In the **Members** list, select the sheet for which you want to set the grid line color.
5. To set the horizontal grid line color,
    1. Select the **HorizontalGridLine** object in the property list.
    2. If you want to display three-dimensional grid lines, set the **Type** property to **Lowered** or **Raised**.
    3. If the grid lines are not three-dimensional, select the **Color** property, and then click the drop-down button to display the color picker. Select a color in the color picker.
    4. If the grid lines are three-dimensional, select the **HighlightColor** property, and then click the drop-down button to display the color picker. Select a color in the color picker. Do the same for the **ShadowColor** property.
6. To set the vertical grid line color,
    1. Select the **VerticalGridLine** object in the property list
    2. If you want to display three-dimensional grid lines, set the **Type** property to **Lowered** or **Raised**.
    3. If the grid lines are not three-dimensional, select the **Color** property, and then click the drop-down button to display the color picker. Select a color in the color picker.
    4. If the grid lines are three-dimensional, select the **HighlightColor** property, and then click the drop-down button to display the color picker. Select a color in the color picker. Do the same for the **ShadowColor** property.
7. Click **OK** to close the editor.

## Using Code

1. Create a [GridLine](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.GridLine.html) object, setting the color or colors and the style for the grid line in the constructor.
2. Assign the [GridLine](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.GridLine.html) object to the specified sheet by setting the [SheetView](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.html) object [HorizontalGridLine](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.HorizontalGridLine.html) or [VerticalGridLine](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.VerticalGridLine.html) property to the [GridLine](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.GridLine.html) object you created in step 1.

## Example

This example code sets the horizontal grid line color to red and the vertical grid line color to chartreuse. Both grid lines are flat.

```csharp
FarPoint.Win.Spread.GridLine HGridLine = new FarPoint.Win.Spread.GridLine(FarPoint.Win.Spread.GridLineType.Flat, Color.Red);
FarPoint.Win.Spread.GridLine VGridLine = new FarPoint.Win.Spread.GridLine(FarPoint.Win.Spread.GridLineType.Flat, Color.Chartreuse);
fpSpread1.Sheets[0].HorizontalGridLine = HGridLine;
fpSpread1.Sheets[0].VerticalGridLine = VGridLine;
```

```vbnet
Dim HGridLine As New FarPoint.Win.Spread.GridLine(FarPoint.Win.Spread.GridLineType.Flat, Color.Red)
Dim VGridLine As New FarPoint.Win.Spread.GridLine(FarPoint.Win.Spread.GridLineType.Flat, Color.Chartreuse)
fpSpread1.Sheets(0).HorizontalGridLine = HGridLine
fpSpread1.Sheets(0).VerticalGridLine = VGridLine
```

## Using the Spread Designer

1. Select the sheet tab for the sheet for which you want to set the grid line colors.
2. To set the horizontal grid line color,
    1. In the **Appearance** category, select the **HorizontalGridLine** object in the property list.
    2. If you want to display three-dimensional grid lines, set the **Type** property to **Lowered** or **Raised**.
    3. If the grid lines are not three-dimensional, select the **Color** property, and then click the drop-down button to display the color picker. Select a color in the color picker.
    4. If the grid lines are three-dimensional, select the **HighlightColor** property, and then click the drop-down button to display the color picker. Select a color in the color picker. Do the same for the **ShadowColor** property.
3. To set the vertical grid line color,
    1. In the **Appearance** category, select the **VerticalGridLine** object in the property list
    2. If you want to display three-dimensional grid lines, set the **Type** property to **Lowered** or **Raised**.
    3. If the grid lines are not three-dimensional, select the **Color** property, and then click the drop-down button to display the color picker. Select a color in the color picker.
    4. If the grid lines are three-dimensional, select the **HighlightColor** property, and then click the drop-down button to display the color picker. Select a color in the color picker. Do the same for the **ShadowColor** property.
4. From the **File** menu choose **Apply and Exit** to apply your changes to the component and exit Spread Designer.

## See Also

[Customizing the Outline of the Component](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-setappearance/spwin-appearcell/spwin-appearcontrolborder)
[Creating and Customizing Cell Borders](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-setappearance/spwin-appearcell/spwin-cellborder)