# Understanding How Cell Types Work

Learn how to specify cell types for individual cells, columns, rows, or entire sheets using named styles and object parentage in Spread.NET.

## Content

You can specify the cell type for an individual cell, a range of cells, columns, rows, or an entire sheet using named styles. [Object Parentage](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssojbects/spwin-knowobjparentage) is also applied to the cell type. The closer to the cell level, the higher the precedence.

## Using Code

Create the cell type you want to apply and set it in the CellType property of named style and each object. CellType property can be set for the following objects:

| **Objects** | **Class** | **Property** |
| ------- | ----- | -------- |
| Cell | [Cell Class](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.Cell.html) | [CellType Property](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.Cell.CellType.html) |
| Column | [Column Class](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.Column.html) | [CellType Property](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.Column.CellType.html) |
| Row | [Row Class](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.Row.html) | [CellType Property](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.Row.CellType.html) |
| Alternating rows | [AlternatingRow Class](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.AlternatingRow.html) | [CellType Property](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.AlternatingRow.CellType.html) |
| Named style | [NamedStyle Class](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.NamedStyle.html) | [CellType Property](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.NamedStyle.CellType.html) |

You can also determine the cell type of the active cell using [GetCellType](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.GetCellType.html) method of [SheetView](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.html) class. You can check the cell type using the typeof operator in Visual Basic and is operator in C#.

## Example

This example code sets the cell type for rows, columns and specific cells.

```csharp
// Set general cell in the entire first row.
fpSpread1.ActiveSheet.Rows[0].CellType = new FarPoint.Win.Spread.CellType.GeneralCellType();

// Set button cell for the entire second column.
FarPoint.Win.Spread.CellType.ButtonCellType buttonCell = new FarPoint.Win.Spread.CellType.ButtonCellType();
buttonCell.Text = "Button";
fpSpread1.ActiveSheet.Columns[1].CellType = buttonCell;

// Set date-time cell only for the first row and first column.
FarPoint.Win.Spread.CellType.DateTimeCellType datecell = new FarPoint.Win.Spread.CellType.DateTimeCellType();
datecell.DateTimeFormat = FarPoint.Win.Spread.CellType.DateTimeFormat.ShortDate;
fpSpread1.ActiveSheet.Cells[0, 0].CellType = datecell;
fpSpread1.ActiveSheet.Cells[0, 0].Value = System.DateTime.Now;
```

```vbnet
' Set general cell in the entire first row.
FpSpread1.ActiveSheet.Rows(0).CellType = New FarPoint.Win.Spread.CellType.GeneralCellType()

' Set button cell for the entire second column.
Dim buttonCell As New FarPoint.Win.Spread.CellType.ButtonCellType()
buttonCell.Text = "Button"
FpSpread1.ActiveSheet.Columns(1).CellType = buttonCell

' Set date-time cell only for the first row and first column.
Dim datecell As New FarPoint.Win.Spread.CellType.DateTimeCellType()
datecell.DateTimeFormat = FarPoint.Win.Spread.CellType.DateTimeFormat.ShortDate
FpSpread1.ActiveSheet.Cells(0, 0).CellType = datecell
FpSpread1.ActiveSheet.Cells(0, 0).Value = System.DateTime.Now
```

## See Also

[Cell Types](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-setcelltypes)
[Understanding Cell Type Basics](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-setcelltypes/spwin-celltypeoview)
[Understanding How Cell Types Display and Format Data](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-setcelltypes/spwin-datacelltextvalue)
[Understanding How Cell Type Affects Model Data](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-setcelltypes/spwin-celltypedatatomodel)
[Working with Editable Cell Types](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-setcelltypes/spwin-seteditcelltypes)
[Working with Graphical Cell Types](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-setcelltypes/spwin-setgraphcelltypes)
[Understanding Additional Features of Cell Types](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-setcelltypes/spwin-celltypecustomize)
[Cell Types](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-setcelltypes)
[Understanding Cell Type Basics](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-setcelltypes/spwin-celltypeoview)
[Understanding How Cell Types Display and Format Data](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-setcelltypes/spwin-datacelltextvalue)
[Understanding How Cell Type Affects Model Data](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-setcelltypes/spwin-celltypedatatomodel)
[Working with Editable Cell Types](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-setcelltypes/spwin-seteditcelltypes)
[Working with Graphical Cell Types](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-setcelltypes/spwin-setgraphcelltypes)
[Understanding Additional Features of Cell Types](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-setcelltypes/spwin-celltypecustomize)