Hi guys.
I wanted to add custom summary at the footer of wingrid, and i want the sum to be divided by 1000.
Please share with to customize the summary.
Thanks.
You have to implement the ICustomSummaryCalculator interface and assing the implementation to the SummarySettings.CustomSummaryCalculator property.
Example:SummarySettings ss = this.ultraGrid1.DisplayLayout.Bands[0].Summaries.Add(SummaryType.Sum, this.ultraGrid1.DisplayLayout.Bands[0].Columns["Summary"]);ss.SummaryType = SummaryType.Custom;ss.CustomSummaryCalculator = new SummaryCalculator();
public class SummaryCalculator : ICustomSummaryCalculator{ private double total = 0;
public void AggregateCustomSummary(SummarySettings settings, UltraGridRow row) { string cellValue = row.Cells[settings.SourceColumn].Text; double val = 0; if ( double.TryParse(cellValue, out val) ) this.total += (val / 1000); }
public void BeginCustomSummary(SummarySettings settings, RowsCollection rows) { this.total = 0; }
public object EndCustomSummary(SummarySettings settings, RowsCollection rows) { return this.total; }
}
Hi Brian, your codes work perfectly.
But one more question, how can I change the 'Summary= ....' (at footer) to 'Sum=.....' ???
ss.DisplayFormat = "Sum={0}"
Brian and Mike, million thanks for your codes.
They work perfectly.