Back to Devexpress

Worksheet.FreezeColumns(Int32, CellRange) Method

officefileapi-devexpress-dot-spreadsheet-dot-worksheet-dot-freezecolumns-x28-system-dot-int32-devexpress-dot-spreadsheet-dot-cellrange-x29.md

latest3.5 KB
Original Source

Worksheet.FreezeColumns(Int32, CellRange) Method

Freezes the specified number of columns to the right of the specified cell, including the column that contains this cell.

Namespace : DevExpress.Spreadsheet

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
void FreezeColumns(
    int columnOffset,
    CellRange topLeft
)
vb
Sub FreezeColumns(
    columnOffset As Integer,
    topLeft As CellRange
)

Parameters

NameTypeDescription
columnOffsetInt32

An integer value that specifies the zero-based offset of the last column to be frozen relative to the column that contains the specified cell (the topLeft parameter).

| | topLeft | CellRange |

A CellRange object that specifies a cell (or top left cell of the cell range) contained in a column from where freezing columns shall start.

|

Remarks

The FreezeColumns method locks columns on the left side of the worksheet, starting from the column that contains the topLeft cell and ending with the column specified by columnOffset relative to the first frozen column. Frozen columns are visible while the remaining area of the worksheet is scrolled.

To freeze worksheet rows, or to freeze both rows and columns, use the Worksheet.FreezeRows or Worksheet.FreezePanes method.

To unfreeze panes in a worksheet, use the Worksheet.UnfreezePanes method.

The following example demonstrates how to use the FreezeColumns method to freeze three columns starting with column C.

csharp
using DevExpress.Spreadsheet;
// ...

Worksheet worksheet = workbook.Worksheets[0];
worksheet.FreezeColumns(2, worksheet.Cells["C7"]);
vb
Imports DevExpress.Spreadsheet
' ...

Dim worksheet As Worksheet = workbook.Worksheets(0)
worksheet.FreezeColumns(2, worksheet.Cells("C7"))

The following image shows the result of executing the code above. Columns from C through E are always visible. Other columns from F through the last column of the worksheet can be scrolled. The worksheet is fully scrollable vertically, by rows.

See Also

FreezeRows

FreezePanes

UnfreezePanes()

Worksheet Interface

Worksheet Members

DevExpress.Spreadsheet Namespace