Back to Devexpress

Group Management: Ungroup Rows and/or Columns

vcl-168052-expressspreadsheet-concepts-groups-group-management-ungrouping-rows-and-or-columns.md

latest6.2 KB
Original Source

Group Management: Ungroup Rows and/or Columns

  • Mar 20, 2026
  • 3 minutes to read

The Spreadsheet Control provides multiple options for ungrouping the columns and rows:

The Delete procedure, implemented in the TdxSpreadSheetTableItemGroups class, can perform the following actions:

  • Delete the entire group of table items at the highest nesting level if the AStartIndex and AFinishIndex parameters match the group’s StartIndex and FinishIndex property values:

  • Shrink the group of columns or rows if either the AStartIndex or AFinishIndex parameter matches the group’s StartIndex or FinishIndex property value:

  • Split the target group into two groups of columns or rows if the range of table items specified using AStartIndex and AFinishIndex parameters, lies within the grouped range specified as the group’s StartIndex and FinishIndex property values:

To allow an end-user to ungroup columns and rows, you can use the information on selected areas within the currently active worksheet. For instance, an implementation of the ungroup command can use the left and right bounds of the Table View worksheet’s Selection.Area rectangle as the AStartIndex and AFinishIndex parameters of the Columns.Groups.Delete procedure, respectively:

delphi
var
  ATableView: TdxSpreadSheetTableView;
  AFirstColumn, ALastColumn: Integer;
//...
  ATableView := dxSpreadSheet1.ActiveSheetAsTable;
  AFirstColumn := ATableView.Selection.Area.Left;
  ALastColumn := ATableView.Selection.Area.Right;
  if(ATableView.Selection.Count > 0) then
    ATableView.Columns.Groups.Delete(AFirstColumn, ALastColumn);
cpp
TdxSpreadSheetTableView* ATableView;
  int AFirstColumn, ALastColumn;
//...
  ATableView = dxSpreadSheet1->ActiveSheetAsTable;
  AFirstColumn = ATableView->Selection->Area.Left;
  ALastColumn = ATableView->Selection->Area.Right;
  if(ATableView->Selection->Count > 0)
  {
    ATableView->Columns->Groups->Delete(AFirstColumn, ALastColumn);
  }

In the case of row ungrouping, you can use the top and bottom bounds of the same Selection.Area rectangle as the AStartIndex and AFinishIndex parameters of the Rows.Groups.Delete procedure, respectively:

delphi
var
  ATableView: TdxSpreadSheetTableView;
  AFirstRow, ALastRow: Integer;
//...
  ATableView := dxSpreadSheet1.ActiveSheetAsTable;
  AFirstRow := ATableView.Selection.Area.Top;
  ALastRow := ATableView.Selection.Area.Bottom;
  if(ATableView.Selection.Count > 0) then
    ATableView.Rows.Groups.Delete(AFirstColumn, ALastColumn);
cpp
TdxSpreadSheetTableView* ATableView;
  int AFirstRow, ALastRow;
//...
  ATableView = dxSpreadSheet1->ActiveSheetAsTable;
  AFirstRow = ATableView->Selection.Area.Top;
  ALastRow = ATableView->Selection.Area.Bottom;
  if(ATableView->Selection->Count > 0)
  {
    ATableView->Rows->Groups->Delete(AFirstRow, ALastRow);
  }

To implement the “ungroup all columns” and “ungroup all rows” commands, use the Table View‘s Columns.Groups.DeleteAll and Rows.Groups.DeleteAll procedures, respectively.