Back to Devexpress

RowCollection.Group(Int32, Int32, Boolean) Method

officefileapi-devexpress-dot-spreadsheet-dot-rowcollection-dot-group-x28-system-dot-int32-system-dot-int32-system-dot-boolean-x29.md

latest7.3 KB
Original Source

RowCollection.Group(Int32, Int32, Boolean) Method

Groups the specified rows on a worksheet.

Namespace : DevExpress.Spreadsheet

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

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
void Group(
    int first,
    int last,
    bool collapse
)
vb
Sub Group(
    first As Integer,
    last As Integer,
    collapse As Boolean
)

Parameters

NameTypeDescription
firstInt32

A zero-based integer representing the index of the first row to be grouped.

| | last | Int32 |

A zero-based integer representing the index of the last row to be grouped.

| | collapse | Boolean |

true , if the created group is collapsed; otherwise, false.

|

Example

To group rows in a worksheet, call the RowCollection.Group method of the RowCollection object. This object represents a collection of all rows contained in a worksheet and is accessed via the Worksheet.Rows property. Pass the indexes of the first and last rows to be grouped, and a value indicating whether the new group should be expanded or collapsed.

Note that you can also place one group of rows inside another. But the number of nested groups is limited: you can create a maximum of seven levels of grouping. The example below demonstrates how two create two levels of grouping.

View Example

csharp
// Group four rows starting from the third row and collapse the group.
worksheet.Rows.Group(2, 5, true);

// Group four rows starting from the ninth row and expand the group.
worksheet.Rows.Group(8, 11, false);

// Create the outer group of rows by grouping rows 2 through 13. 
worksheet.Rows.Group(1, 12, false);
vb
' Group four rows starting from the third row and collapse the group.
worksheet.Rows.Group(2, 5, True)

' Group four rows starting from the ninth row and expand the group.
worksheet.Rows.Group(8, 11, False)

' Create the outer group of rows by grouping rows 2 through 13. 
worksheet.Rows.Group(1, 12, False)

The following code snippets (auto-collected from DevExpress Examples) contain references to the Group(Int32, Int32, Boolean) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-spreadsheetcontrol-api-part-2/CS/SpreadsheetControl_API_Part02/SpreadsheetActions/GroupAndOutlineActions.cs#L30

csharp
// Group four rows starting from the third row and collapse the group.
worksheet.Rows.Group(2, 5, true);

wpf-spreadsheetcontrol-api-part-2/CS/SpreadsheetControl_WPF_API_Part02/SpreadsheetActions/GroupAndOutlineActions.cs#L30

csharp
// Group four rows starting from the third row and collapse the group.
worksheet.Rows.Group(2, 5, true);

spreadsheet-document-api-examples-part2/CS/SpreadsheetDocServerAPIPart2/CodeExamples/GroupAndOutlineActions.cs#L23

csharp
// Group rows 3 through 6 and collapse the group.
worksheet.Rows.Group(2, 5, true);

spreadsheet-document-api-examples-part1/CS/SpreadsheetExamples/SpreadsheetActions/RowAndColumnActions.cs#L212

csharp
// Group ten rows (from the second row to the eleventh row).
worksheet.Rows.Group(1, 10, false);
#endregion #GroupRows

winforms-spreadsheetcontrol-api-part-2/VB/SpreadsheetControl_API_Part02/SpreadsheetActions/GroupAndOutlineActions.vb#L26

vb
' Group four rows starting from the third row and collapse the group.
worksheet.Rows.Group(2, 5, True)

wpf-spreadsheetcontrol-api-part-2/VB/SpreadsheetControl_WPF_API_Part02/SpreadsheetActions/GroupAndOutlineActions.vb#L26

vb
' Group four rows starting from the third row and collapse the group.
worksheet.Rows.Group(2, 5, True)

spreadsheet-document-api-examples-part2/VB/SpreadsheetDocServerAPIPart2/CodeExamples/GroupAndOutlineActions.vb#L20

vb
' Group rows 3 through 6 and collapse the group.
worksheet.Rows.Group(2, 5, True)

spreadsheet-document-api-examples-part1/VB/SpreadsheetExamples/SpreadsheetActions/RowAndColumnActions.vb#L170

vb
' Group ten rows (from the second row to the eleventh row).
            worksheet.Rows.Group(1, 10, False)
#End Region ' #GroupRows

See Also

How to: Outline Data Manually

RowCollection Interface

RowCollection Members

DevExpress.Spreadsheet Namespace