All docs
V19.2
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET Core 3.0+
Row

CellRange.Resize(Int32, Int32) Method

Resizes the current cell range.

Namespace: DevExpress.Spreadsheet

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

Declaration

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

Parameters

Name Type Description
rowCount Int32

The number of rows in the new range.

columnCount Int32

The number of columns in the new range.

Parameters

Name Type Description
rowCount Int32

The number of rows in the new range.

columnCount Int32

The number of columns in the new range.

Parameters

Name Type Description
rowCount Int32

The number of rows in the new range.

columnCount Int32

The number of columns in the new range.

Returns

Type Description
CellRange

The resized cell range.

Returns

Type Description
CellRange

The resized cell range.

Returns

Type Description
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:

CellRange selection = 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").

    Spreadsheet_Resize_Horizontal_UnionRange

    In this case, you can change the number of columns in the subranges:

    CellRange unionRange = worksheet.Range.Union(worksheet["B2:D4"], worksheet["B7:D8"]);
    CellRange resizedRange = unionRange.Resize(unionRange.RowCount, unionRange.ColumnCount+1);
    

    The image below shows the resized complex range.

    Spreadsheet_Resize_Horizontal_UnionRange_Resized

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

    Spreadsheet_Resize_Vertical_UnionRange

    In this case, you can change the number of rows in the subranges:

    CellRange unionRange = worksheet.Range.Union(worksheet["B2:C7"], worksheet["E2:E7"]);
    CellRange resizedRange = unionRange.Resize(unionRange.RowCount+1, unionRange.ColumnCount);
    

    The image below shows the resized complex range.

    Spreadsheet_Resize_Vertical_UnionRange_Resized

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

See Also