# Setting Frozen and Pinned Rows/Columns

Learn how to set frozen rows and columns in your spreadsheet to make them unscrollable. Understand the difference between leading and trailing frozen rows and columns and how to customize their appearance.

## Content

You can freeze rows or columns or both in a sheet to make them unscrollable.

>type=note
> **Note:** Frozen rows or columns are not scrollable at run time but they are scrollable during design time.

## Set Frozen Rows or Columns

The frozen top rows are called leading rows and the frozen left-most columns are called leading columns. The frozen leading rows and columns stay at the top and left of the view regardless of the scrolling.
You can set the number of frozen rows or columns by using the [FrozenRowCount](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.FrozenRowCount.html) or [FrozenColumnCount](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.FrozenColumnCount.html) properties.
![](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/frozen-cells.png)

```csharp
// freeze rows and columns
FpSpread1.Sheets[0].FrozenColumnCount = 2;
FpSpread1.Sheets[0].FrozenRowCount = 2;
```

```vbnet
'freeze rows And columns
FpSpread1.Sheets(0).FrozenColumnCount = 2
FpSpread1.Sheets(0).FrozenRowCount = 2
```

## Set Trailing Frozen Rows or Columns

The frozen trailing rows and columns stay at the bottom and right of the view regardless of the scrolling.
You can set the number of frozen trailing bottom rows or trailing right-most columns by using [FrozenTrailingColumnCount](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.FrozenTrailingColumnCount.html) or [FrozenTrailingRowCount](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.FrozenTrailingRowCount.html) properties.
![](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/frozen-cells-trailing.png)
When the height of data rows and frozen trailing rows is less than that of the viewport area, you can choose whether to display the blank space between the data rows and frozen trailing rows or not. The [FrozenTrailingStickToEdge](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.FrozenTrailingStickToEdge.html) option can be used to control this behavior and accepts [RowCol](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.RowCol.html) enumeration values such as Both (default), Rows, Columns, None.

| When **FrozenTrailingStickToEdge =** Row | When **FrozenTrailingStickToEdge =** None |
| ------------------------------------ | ------------------------------------- |
| ![Frozen Trailing Rows with stickToEdge Parameter set To True](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/sticktoegdeparamtrue.png) | ![Frozen Trailing Rows with stickToEdge Parameter set To False](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/sticktoegdeparamfalse.png) |

```csharp
fpSpread1.ActiveSheet.Rows.Count = 25;
fpSpread1.ActiveSheet.Columns.Count = 20;
fpSpread1.Sheets[0].FrozenTrailingRowCount = 5;
fpSpread1.ActiveSheet.FrozenTrailingStickToEdge = FarPoint.Win.Spread.RowCol.Rows;
```

```vbnet
FpSpread1.ActiveSheet.Rows.Count = 25
FpSpread1.ActiveSheet.Columns.Count = 20
FpSpread1.Sheets(0).FrozenTrailingRowCount = 5
FpSpread1.ActiveSheet.FrozenTrailingStickToEdge = FarPoint.Win.Spread.RowCol.Rows
```

>type=note
> **Note:**
> When using the print option, trailing frozen rows and columns are not printed repeatedly at the bottom and right of every page, but print only once as the last row and column.
> Leading frozen rows and columns can be repeatedly printed at the top and left of every page. For more information about repeating rows and columns, refer to [Repeating Rows or Columns on Printed Pages](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-printing/spwin-printcustomize/spwin-printrepeatrange).

## Set Frozen Line Color

You can specify the color of the line displayed between the frozen and non-frozen areas of the worksheet with the [FrozenLineColor](/spreadnet/api/latest/online-win/GrapeCity.Spreadsheet/GrapeCity.Spreadsheet.WorksheetOptions.FrozenLineColor.html) property in the [WorksheetOptions](/spreadnet/api/latest/online-win/GrapeCity.Spreadsheet/GrapeCity.Spreadsheet.WorksheetOptions.html) class. By default, no color is set to show the frozen line.
The preferred frozen line color can be chosen by using [Color methods](/spreadnet/api/latest/online-win/GrapeCity.Spreadsheet/GrapeCity.Spreadsheet.Color.html).
![](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/frozen-cells-color.png)

```csharp
// freeze rows and columns
fpSpread1.Sheets[0].FrozenColumnCount = 2;
fpSpread1.Sheets[0].FrozenRowCount = 2;
fpSpread1.Sheets[0].FrozenTrailingColumnCount = 2;
fpSpread1.Sheets[0].FrozenTrailingRowCount = 2;
// set frozen line color
fpSpread1.AsWorkbook().Worksheets[0].Options.FrozenLineColor = GrapeCity.Spreadsheet.Color.FromArgb(0, 0, 255);
```

```vbnet
'freeze rows And columns
FpSpread1.Sheets(0).FrozenColumnCount = 2
FpSpread1.Sheets(0).FrozenRowCount = 2
FpSpread1.Sheets(0).FrozenTrailingColumnCount = 2
FpSpread1.Sheets(0).FrozenTrailingRowCount = 2
'set frozen line color
FpSpread1.AsWorkbook().Worksheets(0).Options.FrozenLineColor = GrapeCity.Spreadsheet.Color.FromArgb(0, 0, 255)
```

## Set Frozen Line Width

You can specify or change the width of the displayed line between the frozen and non-frozen areas of the worksheet using **FrozenLineThickness** property from the **WorksheetOptions** class.
![](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/frozen-line-width.png)

```csharp
fpSpread1.ActiveSheet.FrozenColumnCount = 3;
fpSpread1.ActiveSheet.AsWorksheet().Options.FrozenLineThickness = 5;
```

```vbnet
fpSpread1.ActiveSheet.FrozenColumnCount = 3
fpSpread1.ActiveSheet.AsWorksheet().Options.FrozenLineThickness = 5
```

## Set Pinned Rows or Columns

Spread Windows Forms provides the [TogglePinnedRows()](/spreadnet/api/latest/online-win/GrapeCity.Spreadsheet/GrapeCity.Spreadsheet.IWorksheet.TogglePinnedRows.html) and [TogglePinnedColumns()](/spreadnet/api/latest/online-win/GrapeCity.Spreadsheet/GrapeCity.Spreadsheet.IWorksheet.TogglePinnedColumns.html) methods to pin rows and columns, keeping them visible at the top or left while scrolling. This is useful for comparing data or keeping important rows or columns in view.
![](https://cdn.mescius.io/document-site-files/images/53cc02a8-8309-45ab-805b-7f04955cf00b/frozen.a59cc6.gif?width=900)
Pinned rows or columns can be used together with frozen rows or columns. If a pinned row is also within the frozen rows, it will be displayed as a frozen row. For example, if you set `FrozenRowCount = 3` and pin rows 1, 5, and 6, the top of the sheet will show the three frozen rows, with the pinned rows (such as 5 and 6) grouped above the rest of the data.
![image](https://cdn.mescius.io/document-site-files/images/53cc02a8-8309-45ab-805b-7f04955cf00b/image.75eb81.png?width=900)
The following example demonstrates how to pin specific rows and columns in the worksheet.
**C#**

```csharp
// Pin specified rows.
fpSpread1.AsWorkbook().ActiveSheet.TogglePinnedRows(0, 4, 5);

// Pin specified columns.
fpSpread1.AsWorkbook().ActiveSheet.TogglePinnedColumns(0, 1, 3);
```

**VB**

```vbnet
' Pin specified rows.
fpSpread1.AsWorkbook().ActiveSheet.TogglePinnedRows(0, 4, 5)

' Pin specified columns.
fpSpread1.AsWorkbook().ActiveSheet.TogglePinnedColumns(0, 1, 3)
```

## Using the Properties Window

1. At design time, in the **Properties** window, select the Sheet.
2. In the **SheetView Collection Editor** (**Appearance** section), set the **FrozenRowCount**, **FrozenColumnCount**, **FrozenTrailingRowCount**, **FrozenTrailingColumnCount**, or the **FrozenTrailingStickToEdge** property.

## Using the Spread Designer

1. Select **Sheet** from the drop-down combo list located on the top right side of the Designer.
2. From the **SheetView Collection Editor**, set the **FrozenColumnCount**, **FrozenRowCount**, **FrozenTrailingColumnCount**, **FrozenTrailingRowCount**, **FrozenTrailingStickToEdge**.
3. From the **File** menu, select **Save and Exit** to save the changes.

## See Also

[Rows and Columns](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-rowcol)
[Customizing the Number of Rows or Columns](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-rowcol/spwin-rowcolnumber)
[Adding a Row or Column](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-rowcol/spwin-rowcoladd)
[Removing a Row or Column](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-rowcol/spwin-rowcolremove)
[Showing or Hiding a Row or Column](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-rowcol/spwin-rowcolhide)
[Setting the Row Height or Column Width](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-rowcol/spwin-rowcolsize)
[Moving Rows or Columns](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-rowcol/spwin-rowcol-usermove)
[Creating Alternating Rows](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-rowcol/spwin-rowcolalt)
[Setting up Preview Rows](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-rowcol/spwin-previewrow)
[Input Data in Rows or Columns](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-rowcol/spwin-rowcol-userentry)
[Rows or Columns That Have Data](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-rowcol/spwin-rowcolnonempty)
[Adding a Tag to a Row or Column](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-rowcol/spwin-tags-rowcol)
[Rows and Columns](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-rowcol)
[Customizing the Number of Rows or Columns](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-rowcol/spwin-rowcolnumber)
[Adding a Row or Column](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-rowcol/spwin-rowcoladd)
[Removing a Row or Column](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-rowcol/spwin-rowcolremove)
[Showing or Hiding a Row or Column](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-rowcol/spwin-rowcolhide)
[Setting the Row Height or Column Width](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-rowcol/spwin-rowcolsize)
[Moving Rows or Columns](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-rowcol/spwin-rowcol-usermove)
[Creating Alternating Rows](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-rowcol/spwin-rowcolalt)
[Setting up Preview Rows](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-rowcol/spwin-previewrow)
[Input Data in Rows or Columns](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-rowcol/spwin-rowcol-userentry)
[Rows or Columns That Have Data](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-rowcol/spwin-rowcolnonempty)
[Adding a Tag to a Row or Column](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-rowcol/spwin-tags-rowcol)