Back to Devexpress

SpreadsheetControl.GroupStateChanging Event

windowsforms-devexpress-dot-xtraspreadsheet-dot-spreadsheetcontrol-389c5b85.md

latest4.6 KB
Original Source

SpreadsheetControl.GroupStateChanging Event

Fires before row or column groups are expanded or collapsed.

Namespace : DevExpress.XtraSpreadsheet

Assembly : DevExpress.XtraSpreadsheet.v25.2.dll

NuGet Package : DevExpress.Win.Spreadsheet

Declaration

csharp
public event GroupStateChangingEventHandler GroupStateChanging
vb
Public Event GroupStateChanging As GroupStateChangingEventHandler

Event Data

The GroupStateChanging event's data class is GroupStateChangingEventArgs. The following properties provide information specific to this event:

PropertyDescription
CancelGets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs.
GroupsReturns information about groups affected by the expand/collapse operation.
IsExpandingIndicates whether a user is going to expand groups.
IsRowGroupIndicates whether a user starts to expand/collapse row groups.

Remarks

The WinForms Spreadsheet control ships with a set of events that allow you to control the expand/collapse operations for row and column groups in a worksheet.

The following events occur when a user clicks a plus / minus symbol on the outline bar (or the Hide Detail / Show Detail button on the Data ribbon tab):

The following events occur when a user clicks one of the outline buttons to expand/collapse row or column groups:

The GroupStateChanging event fires before the expand/collapse operation starts. Enable the Cancel property of the event data class to cancel the operation. Event arguments allow you to determine whether a user expands or collapses groups (IsExpanding), check the group type (IsRowGroup), and retrieve information about affected groups (Groups).

The following code snippet prevents users from expanding row groups:

csharp
spreadsheetControl1.GroupStateChanging += (s, e) => {
    if (e.IsRowGroup && e.IsExpanding)
        e.Cancel = true;
};
vb
AddHandler spreadsheetControl1.GroupStateChanging,
  Sub(s, e)
    If e.IsRowGroup AndAlso e.IsExpanding Then
      e.Cancel = True
    End If
  End Sub

See Also

SpreadsheetControl Class

SpreadsheetControl Members

DevExpress.XtraSpreadsheet Namespace