如果我想同时使用gridView.EndDataUpdate (gridView.BeginDataUpdate)和gridView.EndSummaryUpdate (gridView.BeginSummaryUpdate),哪一个应该是正确的顺序?
订单1:
gridView.BeginDataUpdate();
gridView.BeginSummaryUpdate();
...
gridView.EndSummaryUpdate();
gridView.EndDataUpdate();订单2:
gridView.BeginDataUpdate();
gridView.BeginSummaryUpdate();
...
gridView.EndDataUpdate();
gridView.EndSummaryUpdate();当我应该使用gridView.EndUpdate (gridView.BeginUpdate)的时候,有什么顺序要求吗?
谢谢!!
发布于 2012-08-08 12:39:59
BaseView.BeginUpdate/BaseView.EndUpdate方法锁定视图并阻止后续的可视化更新。使用BeginUpdate和EndUpdate方法无法避免任何数据更新。相反,必须使用BaseView.BeginDataUpdate和BaseView.EndDataUpdate方法。只要将摘要项添加到网格视图或修改其设置,网格就会自动重新计算摘要。若要在所有汇总项正确初始化之前阻止汇总计算,请使用BeginSummaryUpdate和EndSummaryUpdate方法。
以下是所有这些方法用法的详细描述:
在您的案例中,您可以使用可视化更新来封装数据和摘要更新,如下所示:
view.BeginUpdate();
try {
...view options modifications...
view.BeginDataUpdate();
try {
...data modifications...
}
finally{ view.EndDataUpdate(); } // real data update here
view.BeginSummaryUpdate();
try {
...summary modifications...
}
finally{ view.EndSummaryUpdate(); } // real summary recalculation
...another view options modifications...
}
finally{ view.EndUpdate(); } // real visual updatehttps://stackoverflow.com/questions/11853314
复制相似问题