//--------------------------------------------------------------------------------

// 功能:设定 DbGridEh 合计行信息

// 参数: pDbGrid:TDBGridEh;

//        pcFields : string ; 字段列表,字段用逗号分隔

//        pvtType : TFooterValueType ; 统计类型 TFooterValueType = (fvtNon, fvtSum, fvtAvg, fvtCount, fvtFieldValue, fvtStaticText);

// 引用:StrToStringList

// 例如:DbGridEhFoot( DbGridEh1, 'Number,Sum', fvtSum ); 设定数量和金额字段为合计统计

//--------------------------------------------------------------------------------

Procedure DbGridEhFoot( pDbGrid:TDBGridEh; pcFields: string; pvtType : TFooterValueType );

var nFldLoop : integer ;

    cFieldName : string ;

    tmpFldList : TStrings ;

begin

  pDbGrid.FooterRowCount := 1;    // 指定网格尾部统计行行数

  pDbGrid.SumList.Active := true;   // 激活统计

  pDbGrid.FooterColor    := clBtnFace ;  // 指定统计行颜色

  tmpFldList := TStringList.Create ;

  StrToStringList( Uppercase(pcFields),',',tmpFldList );  // 将字符串转换为串列表

  For nFldLoop := 0 to pDbGrid.Columns.Count -1 do

  begin

      cFieldName := pDbGrid.Columns[nFldLoop].FieldName ;  // 网格列字段名

      if tmpFldList.IndexOf( uppercase( cFieldName ) ) >= 0 then

      begin

         pDbGrid.Columns[nFldLoop].Footer.ValueType := pvtType ;  // 统计类型

      end;

  end ;

  tmpFldList.Free ;

end;

posted on 2008-11-12 01:00  漂流侠  阅读(829)  评论(0编辑  收藏  举报