Devexpress Gridview提供的Summary只有简单的SUM,Avg,Count等,实际上有时候这并不能满足我们的需求,不用担心,DEV提供了这个事件CustomSummaryCalculate,可以自定义算法。以下是个简单的例子:
private void gridview1_CustomSummaryCalculate(object sender,
DevExpress.Data.CustomSummaryEventArgs e)
{
if(((DevExpress.XtraGrid.GridSummaryItem)e.Item).FieldName=="perce")
{
double total = Convert.ToDouble(colTotal.SummaryItem.SummaryValue);
double Obtained =
Convert.ToDouble(colObtained.SummaryItem.SummaryValue);
if (totalMarks != 0)
{
e.TotalValue = Obtained / total * 100;
}
else
{
e.TotalValue = 0;
}
}
}