Back to Devexpress

ColumnCollection.Group(Int32, Int32, Boolean) Method

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

latest7.2 KB
Original Source

ColumnCollection.Group(Int32, Int32, Boolean) Method

Groups the specified columns 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 column to be grouped.

| | last | Int32 |

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

| | collapse | Boolean |

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

|

Example

To group columns in a worksheet, call the ColumnCollection.Group method of the ColumnCollection object. This object represents a collection of all columns contained in a worksheet and is accessed using the Worksheet.Columns property. Pass the indexes of the first and last columns 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 columns inside another. But the number of nested groups is limited: you can create a maximum of seven levels of grouping.

View Example

csharp
// Group four columns starting from the third column "C" and expand the group.
worksheet.Columns.Group(2, 5, false);
vb
' Group four columns starting from the third column "C" and expand the group.
worksheet.Columns.Group(2, 5, 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#L53

csharp
// Group four columns starting from the third column "C" and expand the group.
worksheet.Columns.Group(2, 5, false);
#endregion #GroupColumns

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

csharp
// Group four columns starting from the third column "C" and expand the group.
worksheet.Columns.Group(2, 5, false);
#endregion #GroupColumns

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

csharp
// Group columns "C" through "F" and expand the group.
worksheet.Columns.Group(2, 5, false);
#endregion #GroupColumns

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

csharp
// Group eight columns (from the third column to the tenth column).
worksheet.Columns.Group(2, 9, true);
#endregion #GroupColumns

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

vb
' Group four columns starting from the third column "C" and expand the group.
                    worksheet.Columns.Group(2, 5, False)
' #End Region ' #GroupColumns

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

vb
' Group four columns starting from the third column "C" and expand the group.
                    worksheet.Columns.Group(2, 5, False)
' #End Region ' #GroupColumns

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

vb
' Group columns "C" through "F" and expand the group.
            worksheet.Columns.Group(2, 5, False)
' #End Region ' #GroupColumns

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

vb
' Group eight columns (from the third column to the tenth column).
            worksheet.Columns.Group(2, 9, True)
#End Region ' #GroupColumns

See Also

How to: Outline Data Manually

ColumnCollection Interface

ColumnCollection Members

DevExpress.Spreadsheet Namespace