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.
Unfortunately, activation email could not send to your email. Please try again.

How to create summaries for GridGroupingControl that update dynamically based on the current selection?

Thread ID:





104896 Aug 27,2012 09:08 AM Aug 28,2012 09:15 AM Windows Forms 1
Tags: Grouping
Asked On August 27, 2012 09:08 AM

What I'm trying to do is, to display some data in a grid and add a "selection-based-total".

Simply put, it shows the sum of a a particular column in the grid, but only of those rows that are currently selected.

My current approach:
I've created a custom summary class. And to refresh on selection change, I'm doing this:
grid.SelectedRecordsChanged += (sender, e) => grid.Table.InvalidateSummary();

But this doesn't seem to be working.

Any ideas whether this it possible at all? If yes, then how?


Vinish Kumar K [Syncfusion]
Replied On August 28, 2012 09:15 AM

Hi Harshath,

Thank you for your interest in Syncfusion products.

Its possible, you can create a Summaries for GridGroupingControl.Here what i do to create summary. I hope this will be very useful for you.

// Setting summary -                                      

            GridSummaryColumnDescriptor sd1 = new GridSummaryColumnDescriptor();
            sd1.Name = "Net";
            sd1.DataMember = "Net";
            sd1.DisplayColumn = "Net";
            sd1.Format = "{Total}";
            sd1.SummaryType = SummaryType.Custom;

            this.gridGroupingControl.TableDescriptor.Columns.IsModified = true;

            this.gridGroupingControl.TableDescriptor.SummaryRows.Add(new GridSummaryRowDescriptor("Row 1", "Total", new GridSummaryColumnDescriptor[] { sd1 }));

       this.gridGroupingControl.TableDescriptor.Appearance.AnySummaryCell.HorizontalAlignment = GridHorizontalAlignment.Center;
            this.gridGroupingControl.TableDescriptor.Appearance.AnySummaryCell.BackColor = Color.FromArgb(218, 234, 255);

Then you can hook a SelectedRecordsChanged in your Grid.

Refer the following code this may useful. Its working.

private void gridGroupingControl_SelectedRecordsChanged(object sender, SelectedRecordsChangedEventArgs e)
            if (gridGroupingControl.Table.SelectedRecords != null && gridGroupingControl.Table.SelectedRecords.Count != 0)

Please let me know if you have any further concerns.

Vinish Kumar K.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.