控制cxGrid 主从表的明细只展开一个

procedure TForm.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 TForm.ADetailDataControllerExpanding(
  ADataController: TcxCustomDataController; ARecordIndex: Integer;
  var AAllow: Boolean);
begin
  ADataController.CollapseDetails;
end;

procedure TForm.FormCreate(Sender: TObject);
begin
  inherited;
  //控制只展开一个明细
  cxGridVMain.DataController.OnDetailExpanding := ADetailDataControllerExpanding;
  cxGridVMain.DataController.OnDetailCollapsing := ADetailDataControllerCollapsing;

end;

 


posted @ 2014-11-14 13:23  ypq  阅读(1476)  评论(0编辑  收藏  举报