zoukankan      html  css  js  c++  java
  • dxGrid使用实例

    //Delphi
    procedure TForm1.ButtonLevelUpClick(Sender: TObject);
    var
      ARecord: TcxCustomGridRecord;
    begin
      with TcxCustomGridTableView(Grid.FocusedView) do

     

      begin
        ARecord := Controller.FocusedRecord;
        if Assigned(ARecord) then
        begin
          ARecord := ARecord.ParentRecord;
          if Assigned(ARecord) then
            ARecord.Focused := True;
        end;
      end;
    end;

     
     
     

    //Delphi
    procedure TForm1.ButtonLevelDownClick(Sender: TObject);

     

      function GetFirstChild(ARecord: TcxCustomGridRecord): TcxCustomGridRecord;
      begin
        if ARecord is TcxGridMasterDataRow then
          Result := ARecord.GetFirstFocusableChild
        else
          if ARecord is TcxGridGroupRow then
            Result := ARecord.ViewData.Records[ARecord.Index + 1]
          else
            Result := nil;

     

      end;

     

    var
      ARecord: TcxCustomGridRecord;
    begin
      with TcxCustomGridTableView(Grid.FocusedView) do
      begin
        ARecord := Controller.FocusedRecord;
        if Assigned(ARecord) then
        begin
          ARecord.Expand(False);
          ARecord := Controller.FocusedRecord;
          ARecord := GetFirstChild(ARecord);
          if Assigned(ARecord) then
            ARecord.Focused := True;
        end;

     

      end;
    end;

     

    如TableView是为TcxDBTableView的话,那  
      TableView.DataController.Groups.ChildCount(1); //这里得到的是第一个组的总数  
      看看下面我以前写的一段代码  
          for i := 0 to Tableview.Controller.SelectedRowCount - 1 do  
              begin  
                  //判断选择的是否为组的行  
                  if TableView.Controller.SelectedRows[i] is TcxGridGroupRow then  
                  begin  
                      //取得组的行的index;  
                      GRowIndex := TableView.Controller.SelectedRows[i].Index;  
                      //取得组的行的ID;  
                      GRowID := TableView.DataController.Groups.DataGroupIndexByRowIndex[GRowIndex];  
                      //这里得到的是组的行的那个标题  
                      ShowMessage(TableView.DataController.Groups.GroupValues[GRowID]);  
                      //这里是组的行数  
                      ShowMessage(IntToStr(TableView.DataController.Groups.ChildCount[GRowID]));  
                  end;  
              end;  

     

      end;

     

    procedure TForm1.CalculateGroupAverage(ADataGroupIndex: TcxDataGroupIndex); 
    var 
      AMengeTo, AGesamt, AVarAverage: Variant; 

     

    begin 
      with gv.DataController.Summary do 
      begin 
        AMengeTo := GroupSummaryValues[ADataGroupIndex, 2]; 
        AGesamt := GroupSummaryValues[ADataGroupIndex, 0]; 
        if not (VarIsNull(AMengeTo) or VarIsNull(AGesamt)) then 
        begin 
          AVarAverage := AGesamt / AMengeTo; 
          GroupSummaryValues[ADataGroupIndex, 3] := FloatToStrF(AVarAverage, ffFixed, 15, 2); 
        end; 
      end; 
    end; 

     

    procedure TForm1.gvDataControllerSummaryAfterSummary( 
      ASender: TcxDataSummary); 

     

    var 
      AChildDataGroupsCount: Integer; 
      AChildDataGroupIndex, AParentDataGroupIndex: TcxDataGroupIndex; 
      AChildPosition: Integer; 
      i: Integer; 
    begin 
      with TcxDataControllerGroups(gv.DataController.Groups) do 
      begin 
        for i := 1 to GroupingItemCount do 
        begin 
          AChildDataGroupsCount := ChildCount[i -2]; 
          for AChildPosition := 0 to AChildDataGroupsCount - 1 do 
          begin 
            AChildDataGroupIndex := ChildDataGroupIndex[i -2, AChildPosition]; 
            CalculateGroupAverage(AChildDataGroupIndex); 
          end; 
        end; 
      end; 
    end; 

  • 相关阅读:
    MySql设计表中的create_time和update_time字段
    java.lang.NoSuchMethodError: scala.Product.$init$(Lscala/Product;)V
    Hbase问题:java.lang.RuntimeException: HRegionServer Aborted
    Elasticsearch 7.6.2 简单的api(springboot)
    idea + springboot 热部署
    kibana Elasticsearch cluster did not respond with license information.
    Elasticsearch7.6.2 搭建的坑
    数据库账号密码加密
    pg数据库,插入数据,若已存在则更新数据
    org.postgresql.util.PSQLException:这个 ResultSet 已经被关闭。
  • 原文地址:https://www.cnblogs.com/djcsch2001/p/2035713.html
Copyright © 2011-2022 走看看