Spread Windows Forms 6.0 Product Documentation
Displaying Grid Lines on a Sheet
Support Options
Spread Windows Forms 6.0 Product Documentation > Developer's Guide > Customizing the Sheet Appearance > Customizing the Individual Sheet Appearance > Displaying Grid Lines on a Sheet

Glossary Item Box

Sheets can 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

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. Basically, the grid line has these properties that can be customized:

The color is for flat lines; the highlight and shadow color are for the other types of lines. Beyond this, the grid lines are non-mutable objects.

You can hide the grid line in a particular direction by setting the type of grid line to None. For example,

FpSpread1.ActiveSheet.HorizontalGridLine = New FarPoint.Win.Spread.GridLine(FarPoint.Win.Spread.GridLineType.None)

To customize other properties, you would create a new GridLine object (rather that 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 class, and HorizontalGridLine property or VerticalGridLine property of the SheetView class.

Note: You can display lines around individual cells by setting cell borders. For more information, refer to Customizing Cell Borders.

For information on setting the grid lines in a header, refer to Customizing the Header Grid Lines.

Return to Customizing the Individual Sheet Appearance.

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 object, setting the color or colors and the style for the grid line in the constructor.
  2. Assign the GridLine object to the specified sheet by setting the SheetView object HorizontalGridLine or VerticalGridLine property to the GridLine 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.

C# Copy Code
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;
 
VB Copy Code
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.
© 2002-2012 ComponentOne, a division of GrapeCity. All Rights Reserved.