JOC快速开发框架 表格值改变更新合计
需求:
表格中有单价和数量两个可编辑列,还有一个金额列,金额列计算为单价*数量,金额列还有一个footer统计合计
主表还有合计字段
当单价和数量任意一个改变时刷新合计
实现方法
利用表格GridView的CellValueChanged事件来更新合计
C# 全选
/// <summary>
/// 单元格值改变
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void gvDetail_DeviceStopDetails_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
{
if (e.Column == colD_DeviceStopDetails_Price || e.Column == colD_DeviceStopDetails_StopTimes)
{
var view = sender as GridView;
var current = view.GetRow(e.RowHandle) as DetailDeviceStopDetails;
current.Amount = current.Price * current.StopTimes;
gvDetail_DeviceStopDetails.UpdateTotalSummary();
//var totalAmount = EditData.DetailCollections.Sum(x => x.Amount);
//var totalWizpeAmount = EditData.DetailCollections.Sum(x => x.WipeZero);
//DataBinder.SetEditorBindingValue(txtTotalAmount, totalAmount);
//DataBinder.SetEditorBindingValue(txtWipeZero, totalWizpeAmount);
}
}
版权声明:本文为YES开发框架网发布内容,转载请附上原文出处连接
YESWinform 张国生