windowsforms-devexpress-dot-xtraspreadsheet-dot-spreadsheetcontrol-389c5b85.md
Fires before row or column groups are expanded or collapsed.
Namespace : DevExpress.XtraSpreadsheet
Assembly : DevExpress.XtraSpreadsheet.v25.2.dll
NuGet Package : DevExpress.Win.Spreadsheet
public event GroupStateChangingEventHandler GroupStateChanging
Public Event GroupStateChanging As GroupStateChangingEventHandler
The GroupStateChanging event's data class is GroupStateChangingEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Cancel | Gets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs. |
| Groups | Returns information about groups affected by the expand/collapse operation. |
| IsExpanding | Indicates whether a user is going to expand groups. |
| IsRowGroup | Indicates whether a user starts to expand/collapse row groups. |
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):
GroupStateChangingThe 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:
spreadsheetControl1.GroupStateChanging += (s, e) => {
if (e.IsRowGroup && e.IsExpanding)
e.Cancel = true;
};
AddHandler spreadsheetControl1.GroupStateChanging,
Sub(s, e)
If e.IsRowGroup AndAlso e.IsExpanding Then
e.Cancel = True
End If
End Sub
See Also