Add a summary item to DevExpress Grid Control column

How to manually generate summary in DeveExpress Grid Control [C#.Net]

Right click [Footer] the DevExpress Grid will populate the summary option, which let user to add summary to the footer section.

Can I add Summaries at run-time ?

Yes.

First we need to enable the Footer section.

((GridView)gridControl1.MainView).OptionsView.ShowFooter= true;
var col= ((GridView)gridControl1.MainView).Columns["DR"];
col.Summary.Add(new GridColumnSummaryItem(DevExpress.Data.SummaryItemType.Sum, "DR", "{0:n2}"));

Using Grid Control Column's Summary property can interact with the collection and generate a new summary item.

The above code will generate summary item with sum of DR column and also apply the specified number format.

We can place the code in Load event of WinForm.

winForm
devexpress
grid-control
grid-summary

Write your comment