Back to Devexpress

CellRange.Resize(Int32, Int32) Method

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

latest2.7 KB
Original Source

CellRange.Resize(Int32, Int32) Method

Resizes the current cell range.

Namespace : DevExpress.Spreadsheet

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

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
CellRange Resize(
    int rowCount,
    int columnCount
)
vb
Function Resize(
    rowCount As Integer,
    columnCount As Integer
) As CellRange

Parameters

NameTypeDescription
rowCountInt32

The number of rows in the new range.

| | columnCount | Int32 |

The number of columns in the new range.

|

Returns

TypeDescription
CellRange

The resized cell range.

|

Remarks

Use the Resize method to enlarge or reduce a cell range within a worksheet. This method always takes the range’s top left cell as its starting point. If the resulting range’s height or width is less than one cell or exceeds the maximum number of rows or columns in a worksheet, the Spreadsheet throws an InvalidOperationException.

The following example demonstrates how to extend selection within the Spreadsheet control by one row and one column:

csharp
CellRange selection = spreadsheetControl1.Selection;
selection.Resize(selection.RowCount + 1, selection.ColumnCount + 1).Select();
vb
Dim selection As CellRange = spreadsheetControl1.Selection
selection.Resize(selection.RowCount + 1, selection.ColumnCount + 1).Select()

You can use the Resize method for a union range only if it meets the following requirements:

  • Its subranges start at the same column and have the same width (for example, “B2:D4, B7:D8”).

  • Its subranges start at the same row and have the same height (for example, “B2:C7, E2:E7”):

For other types of union ranges, the Resize method throws an InvalidOperationException.

See Also

CellRange Interface

CellRange Members

DevExpress.Spreadsheet Namespace