如何让 CXGRID 主从表任何时候只能展开一个组

CXGRID   主从表任何时候只能展开一个组  

   

  procedure   TForm1.ADetailDataControllerCollapsing(  

      ADataController:   TcxCustomDataController;   ARecordIndex:   Integer;  

      var   AAllow:   Boolean);  

  var  

      I:   Integer;  

      C:   Integer;  

  begin  

      AAllow   :=   False;  

      C   :=   0;  

      for   I   :=   0   to   ADataController.RecordCount   -   1   do  

      begin  

          if   ADataController.GetDetailExpanding(I)   then  

              Inc(C);  

          if   C   >   1   then  

              AAllow   :=   True;  

        end;  

  end;  

   

  procedure   TForm1.ADetailDataControllerExpanding(  

      ADataController:   TcxCustomDataController;   ARecordIndex:   Integer;  

      var   AAllow:   Boolean);  

  begin  

      ADataController.CollapseDetails;  

  end;  

   

  procedure   TForm1.FormCreate(Sender:   TObject);  

  begin  

      cxGrid1DBTableView1.DataController.OnDetailExpanding   :=   ADetailDataControllerExpanding;  

      cxGrid1DBTableView1.DataController.OnDetailCollapsing   :=   ADetailDataControllerCollapsing;  

  end;  

原文地址:https://www.cnblogs.com/fengju/p/6173762.html