We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Group event

Is it possible to trigger an event when a user deletes/adds a column in the grouping box area?

I need to track the grouping of columns by the user, but I haven't been able to find a way to do that.


1 Reply

VS Vijayarasan Sivanandham Syncfusion Team January 6, 2023 02:41 PM UTC

Hi Michal Dziubek,

To trigger an event when a user adds or deletes a column in the grouping box area of the SfDataGrid control, you can use the CollectionChanged event of the GroupColumnDescriptions property. Here is an example code snippet that demonstrates:

//Event Subscription

this.sfDataGrid1.GroupColumnDescriptions.CollectionChanged += OnGroupColumnDescriptionsCollectionChanged;

//Event customization

private void OnGroupColumnDescriptionsCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)

{

    

     // Your event handling code goes here

     Console.WriteLine("GroupColumnDescriptions CollectionChanged event is triggered : " + e.Action.ToString());

 

}

 


Note that the CollectionChanged event is raised whenever the group column descriptions collection changes, which includes adding or deleting columns as well as moving them within the collection. You can use the Action property of the e parameter passed to the event handler to determine the specific action that triggered the event (e.g. Add, Remove, etc.).


UG Link: https://help.syncfusion.com/windowsforms/datagrid/grouping

API Link: https://help.syncfusion.com/cr/windowsforms/Syncfusion.WinForms.DataGrid.GroupColumnDescriptions.html

Find the sample demo in the attachment.

Regards,

Vijayarasan S


If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.


Attachment: Sample_2ae221b5.zip

Loader.
Up arrow icon