假定
1、要汇总的列为V,财务科目列为C
2、会计科目是有规则的,例如每2位为一个层级
在datacolchanged事件中
select case e.datacol.name
case "V"
dim s as string = e.datarow(“C”)
'先找到当前财务科目的所有上级
dim dic as new dictionary(of datarow,double)
for i as integer = 0 to s.length - 1 step 2
dim x as string = s.substring(i,2)
dim r as datarow = e.datatable.find("C = '" & x &“‘”)
if r isnot nothing then
dic.add(r,r("V") + e.newvalue - e.oldvalue)
end if
next
systemready = false
for each dr as datarow in dic.keys
dr("V") = dic(dr)
next
systemready = true
end select
如果要禁止在科目的父节点输入数值,可以在PrepareEdit事件中
select case e.col.name
case "V"
dim dr as datarow = e.table.datatable.find("C like '" & e.row("C") & "%'")
if dr isnot nothing then
e.cancel = true
end if
end select
[此贴子已经被作者于2020/12/27 17:13:03编辑过]