CellRange.Resize(Int32, Int32) Method
Resizes the current cell range.
Namespace: DevExpress.Spreadsheet
Assembly: DevExpress.Spreadsheet.v24.2.Core.dll
NuGet Package: DevExpress.Spreadsheet.Core
#Declaration
#Parameters
Name | Type | Description |
---|---|---|
row |
Int32 | The number of rows in the new range. |
column |
Int32 | The number of columns in the new range. |
#Returns
Type | Description |
---|---|
Cell |
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”).
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.
Its subranges start at the same row and have the same height (for example, “B2:C7, E2:E7”):
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.
For other types of union ranges, the Resize method throws an InvalidOperationException.