New to Telerik UI for WinForms? Download free 30-day trial

Events

There are two events that are raised, when the data in the RadGridView is grouped. The first one is the GroupByChanging event which is raised before the data is grouped and he second one is the GroupByChanged event raised after the data is grouped.

void radGridView1_GroupByChanging1(object sender, Telerik.WinControls.UI.GridViewCollectionChangingEventArgs e)
{
    e.Cancel = true;
}

Private Sub RadGridView1_GroupByChanging1(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.GridViewCollectionChangingEventArgs) Handles RadGridView1.GroupByChanging
    e.Cancel = True
End Sub

From the event arguments of both events you can access the following data:

  • Action: An enumeration with values: Add, Remove, ItemChanged and Reset.The Action property notifies if a GroupDescriptor is added, removed, modified or the GroupDescriptors collection is cleared.

  • NewItems: A List of added, edited or removedGroupDescriptors. For each GroupDescriptor you can get its GroupNames, Format, Aggregates and Expression.

You are also able to cancel the grouping operation by setting the Cancel property to True

void radGridView1_GroupByChanging1(object sender, Telerik.WinControls.UI.GridViewCollectionChangingEventArgs e)
{
    e.Cancel = true;
}

Private Sub RadGridView1_GroupByChanging1(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.GridViewCollectionChangingEventArgs) Handles RadGridView1.GroupByChanging
    e.Cancel = True
End Sub

Since the GroupDescriptors collection implements the INotifyPropertyChanged interface, you can use its CollectionChanged event:

radGridView1.GroupDescriptors.CollectionChanged += new Telerik.WinControls.Data.NotifyCollectionChangedEventHandler(GroupDescriptors_CollectionChanged);

AddHandler Me.RadGridView1.GroupDescriptors.CollectionChanged, AddressOf GroupDescriptors_CollectionChanged

void GroupDescriptors_CollectionChanged(object sender, Telerik.WinControls.Data.NotifyCollectionChangedEventArgs e)
{
}

Private Sub GroupDescriptors_CollectionChanged(ByVal sender As Object, ByVal e As Telerik.WinControls.Data.NotifyCollectionChangedEventArgs)
End Sub

The arguments of this event provide the same data as the GroupByChanged event.

As of R1 2021 RadGridView offers two new events:

  • GroupSortChanging: Fires when the user changes the sorting of the group. The action can be canceled.
  • GroupSortChanged: Fires after the user has changed the sorting of the group.

The GridViewGroupSortChangingEventArgs gives you access to the GridViewTemplate, GroupDescriptor and the new ListSortDirection.

See Also

In this article