USEGEAR

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

嵌套子表(dx),如何根据从表合计数显示主表记录的颜色

假设用dx已经构建好m/d了,主表不需要更新。
1、在master中有一字段mysum,增加一个对照字段如ctrl_Field,其初始是detail的合计数
2、master根据mysum和ctrl_Field的值对照改变该记录颜色。
复制代码
procedure TFormBase_PayPlan.cxgrdbtblvwGrid1DBTableView_TargetCustomDrawCell(
  Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
  AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
var
  a_sum,b_sum : Currency;
begin
  if VarIsNull(AViewInfo.GridRecord.Values[cxgrdbclmnGrid1DBTableView1is_sum.Index]) then
   a_sum := 0
 else
   a_sum := StrToFloat(AViewInfo.GridRecord.Values[cxgrdbclmnGrid1DBTableView1is_sum.Index]);

    if VarIsNull(AViewInfo.GridRecord.Values[cxgrdbclmnGrid1DBTableView1isd_sum_total.Index]) then
   b_sum := 0
 else
   b_sum := StrToFloat(AViewInfo.GridRecord.Values[cxgrdbclmnGrid1DBTableView1isd_sum_total.Index]);

  if   a_sum  < b_sum  then
  ACanvas.Canvas.Font.Color:= clRed;//clActiveCaption ?????????????????

end;
复制代码

3、在修改数据事件中做修改ctrl_Field的处理如下,目的是修改ctrl_Field在grid中的值:

复制代码
                    // 显示控制
                    i := cxgrdbtblvwGrid1DBTableView_Target.DataController.FocusedRowIndex;
                    j := cxgrdbclmnGrid1DBTableView1isd_sum_total.Index;
                    if VarIsNull(cxgrdbtblvwGrid1DBTableView_Target.DataController.Values[i,j]) then
                       cxgrdbtblvwGrid1DBTableView_Target.DataController.Values[i,j] := cxcrncydt_Sum.Value
                    else
                       cxgrdbtblvwGrid1DBTableView_Target.DataController.Values[i,j] := cxcrncydt_Sum.Value +
                          cxgrdbtblvwGrid1DBTableView_Target.DataController.Values[i,j];//增加处理

{ cxgrdbtblvwGrid1DBTableView_Target.DataController.Values[i,j] := cxcrncydt_Sum.Value +
                          cxgrdbtblvwGrid1DBTableView_Target.DataController.Values[i,j] - ctrl_PaySTDSun;//修改的处理}
                    //end of 显示控制
复制代码

 

posted on   USEGEAR  阅读(289)  评论(0编辑  收藏  举报

编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
点击右上角即可分享
微信分享提示