Spread for ASP.NET 7.0 Product Documentation
Assigning a Cascading Style Sheet to a Cell
See Also Support Options
Spread for ASP.NET 7.0 Product Documentation > Developer's Guide > Customizing the Appearance > Customizing the Appearance of a Cell > Assigning a Cascading Style Sheet to a Cell

Glossary Item Box

You can assign a cascading style sheet (CSS) to a cell or group of cells as a way of conveniently defining the appearance settings of the cell or cells. The CSS class name is a property of the cell type.

This assumes that the RenderCSSClass property in the FpSpread class is set to true, which is the default. If it is set to false, the component uses the in-line style attributes instead of the cascading style sheet.

The CSS Class should be outside the head tag and after the Spread HTML code for best results with strict compliance.

Using Code

  1. Define the CSSClass property for a given cell type.
  2. Assign that cell type to the cell or cells.

Example

The following attaches a style sheet named myCssClass to be used for the specified column header and cells:

C# Copy Code
FarPoint.Web.Spread.GeneralCellType mycelltype = new FarPoint.Web.Spread.GeneralCellType();
myCellType.CssClass = "myCssClass";
FpSpread1.ColumnHeader.Cells[0, 0].CellType = myCellType;
FpSpread1.Cells[0, 1].CellType = myCellType;
VB Copy Code
Dim myCellType As New FarPoint.Web.Spread.GeneralCellType
myCellType.CssClass = "myCssClass"
FpSpread1.ColumnHeader.Cells(0, 0).CellType = myCellType
FpSpread1.Cells(0, 1).CellType = myCellType

Example

When the pointer is over data in the Spread, the mouse cursor turns into an I-beam shape indicating that the user is allowed to edit the information. This happens even if the columns are locked. To have the pointer remain an arrow when hovering over data in the row, or to change the cursor to whatever you want, you can use the CSSClass object, which assigns a cascading style sheet class to a cell. For example, you can use the following code to use a style for the cursor over a locked column.

C# Copy Code
FpSpread1.Sheets[0].Columns[0].Locked = true;
CType(FpSpread1.Sheets[0].StyleModel.GetCompositeInfo(-1, 0, -1, Nothing).CellType, FarPoint.Web.Spread.GeneralCellType).CssClass = "myCell";
VB Copy Code
FpSpread1.Sheets(0).Columns(0).Locked = True
CType(FpSpread1.Sheets(0).StyleModel.GetCompositeInfo(-1, 0, -1, Nothing).CellType, FarPoint.Web.Spread.GeneralCellType).CssClass = "myCell"

Then in HTML code you can add the myCell style:

HTML Copy Code
<style>.myCell { CURSOR: default } </style>

See Also

© 2002-2014 ComponentOne, a division of GrapeCity. All Rights Reserved.