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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to calulate sum of all the columns in the GridSummaryColumnDescriptor collection of a GridSummaryRowDescriptor while on that row.

Thread ID:





52582 Nov 30,2006 03:21 PM UTC Dec 5,2006 09:33 AM UTC WinForms 1
Tags: Grouping
James Blibo
Asked On November 30, 2006 03:21 PM UTC

I have two summary rows define as follows...

GridSummaryColumnDescriptor[] QtySummaryColumns = new GridSummaryColumnDescriptor[SummaryColumnNames.Count];
GridSummaryColumnDescriptor[] DollarSummaryColumns = new GridSummaryColumnDescriptor[SummaryColumnNames.Count];

for (int i = 0; i < SummaryColumnNames.Count; i++)
string columnName = SummaryColumnNames[i];
QtySummaryColumns[i] = new GridSummaryColumnDescriptor(string.Format("_Qty{0}{1}", columnName, i), SummaryType.DoubleAggregate, columnName, "{Sum:#,###;(#,###);0}");
DollarSummaryColumns[i] = new GridSummaryColumnDescriptor(string.Format("_Qty{0}{1}", i), SummaryType.Custom, columnName, "{Total:#,###.00;(#,###.00);0.00}");

//summary row -> quantity
rowDescriptor = new GridSummaryRowDescriptor("QtySummaryRow", QtySummaryColumns);

//summary row -> dollars
rowDescriptor = new GridSummaryRowDescriptor("DollarSummaryRow", DollarSummaryColumns);

What I want to do is to show the sum of all the summarycolumn in a cell on the same summary row. I want to add another summary column to the summarycolumndescriptor collection as the first summary column to each summary row that will perform a sum ACROSS all the columns in the QtySummaryColumns
GridSummaryColumnDescriptor and do the same for the DollarSummaryColumns.

Is this possible?

Should I just have an SummaryEmptyCell and manually populate that cell with the calculated value using the QueryCellStyleInfo event? How would I accomplish this?

Administrator [Syncfusion]
Replied On December 5, 2006 09:33 AM UTC

Hi James,

This can be achieved by handling the QueryCellStyleInfo event and set the value of SummaryEmptyCell text to sum of the all summary value present in a summary row. You can use the GetSummaries method to get all updated summaries in a GridGroup. Here is a code snippet to show this.

private void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
if( e.TableCellIdentity.TableCellType == GridTableCellType.SummaryEmptyCell )
Element el = e.TableCellIdentity.DisplayElement;
GridTable table = e.TableCellIdentity.Table;
GridSummaryRow row = e.TableCellIdentity.DisplayElement as GridSummaryRow;
GridSummaryRowDescriptor summaryRowDescriptor = row.SummaryRowDescriptor;
int sum = 0;
foreach( ISummary summary in el.ParentGroup.GetSummaries(table))
Int32AggregateSummary Int32summary = summary as Int32AggregateSummary;
if( Int32summary != null)
sum += Int32summary.Sum ;
e.Style.Text = sum.ToString() ;
e.Style.BackColor = Color.DeepPink;

Here is a sample.

Best Regards,


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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon 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.Close Icon